On Wednesday 04 of December 2013, NAKAMURA Takumi wrote:
> I have reverted this. It triggered crashes on check-clang with +Asserts.
>
> http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/11922

 It seems unknown pragmas in STDC namespace are handled specially. Ok to push 
the patch again with the attached addition? All tests now pass even with 
assertions enabled here.

> 2013/12/4 Joerg Sonnenberger <[email protected]>:
> > On Wed, Dec 04, 2013 at 10:21:41AM -0000, Lubos Lunak wrote:
> >> Author: llunak
> >> Date: Wed Dec  4 04:21:41 2013
> >> New Revision: 196372
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=196372&view=rev
> >> Log:
> >> do not warn about unknown pragmas in modes that do not handle them
> >> (pr9537)
> >>
> >> And refactor to have just one place in code that sets up the empty
> >> pragma handlers.
> >
> > Test case?

 ... Subversion ... It actually is in the patch, I'll remember to svn add it.

> > Otherwise, thanks for looking at this. Bill -- is it harmless 
> > enough to include in 3.4?

-- 
 Lubos Lunak
diff --git a/lib/Lex/Pragma.cpp b/lib/Lex/Pragma.cpp
index 61bd917..b9f40d9 100644
--- a/lib/Lex/Pragma.cpp
+++ b/lib/Lex/Pragma.cpp
@@ -1410,5 +1410,16 @@ void Preprocessor::IgnorePragmas() {
   // in Preprocessor::RegisterBuiltinPragmas().
   AddPragmaHandler("GCC", new EmptyPragmaHandler());
   AddPragmaHandler("clang", new EmptyPragmaHandler());
+  if (PragmaHandler *NS = PragmaHandlers->FindHandler("STDC")) {
+    // Preprocessor::RegisterBuiltinPragmas() already registers
+    // PragmaSTDC_UnknownHandler as the empty handler, so remove it first,
+    // otherwise there will be an assert about a duplicate handler.
+    PragmaNamespace *STDCNamespace = NS->getIfNamespace();
+    assert(STDCNamespace &&
+           "Invalid namespace, registered as a regular pragma handler!");
+    if (PragmaHandler *Existing = STDCNamespace->FindHandler("", false)) {
+      RemovePragmaHandler("STDC", Existing);
+    }
+  }
   AddPragmaHandler("STDC", new EmptyPragmaHandler());
 }
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to