[cfe-commits] r127692 - in /cfe/trunk: lib/Sema/SemaExceptionSpec.cpp test/CXX/except/except.spec/p3.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Tue Mar 15 13:41:09 PDT 2011


Author: cornedbee
Date: Tue Mar 15 15:41:09 2011
New Revision: 127692

URL: http://llvm.org/viewvc/llvm-project?rev=127692&view=rev
Log:
More robust check for the special C++0x operator new workaround.

Modified:
    cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
    cfe/trunk/test/CXX/except/except.spec/p3.cpp

Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExceptionSpec.cpp?rev=127692&r1=127691&r2=127692&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExceptionSpec.cpp Tue Mar 15 15:41:09 2011
@@ -396,14 +396,14 @@
         if (Name && Name->getName() == "bad_alloc") {
           // It's called bad_alloc, but is it in std?
           DeclContext* DC = ExRecord->getDeclContext();
-          while (DC && !isa<NamespaceDecl>(DC))
-            DC = DC->getParent();
-          if (DC) {
-            NamespaceDecl* NS = cast<NamespaceDecl>(DC);
+          DC = DC->getEnclosingNamespaceContext();
+          if (NamespaceDecl* NS = dyn_cast<NamespaceDecl>(DC)) {
             IdentifierInfo* NSName = NS->getIdentifier();
+            DC = DC->getParent();
             if (NSName && NSName->getName() == "std" &&
-                isa<TranslationUnitDecl>(NS->getParent()))
+                DC->getEnclosingNamespaceContext()->isTranslationUnit()) {
               return false;
+            }
           }
         }
       }

Modified: cfe/trunk/test/CXX/except/except.spec/p3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/except/except.spec/p3.cpp?rev=127692&r1=127691&r2=127692&view=diff
==============================================================================
--- cfe/trunk/test/CXX/except/except.spec/p3.cpp (original)
+++ cfe/trunk/test/CXX/except/except.spec/p3.cpp Tue Mar 15 15:41:09 2011
@@ -97,9 +97,9 @@
 // As a very special workaround, we allow operator new to match no spec
 // with a throw(bad_alloc) spec, because C++0x makes an incompatible change
 // here.
-namespace std { class bad_alloc {}; }
+extern "C++" { namespace std { class bad_alloc {}; } }
 void* operator new(unsigned long) throw(std::bad_alloc);
 void* operator new(unsigned long);
-void* operator new[](unsigned long) throw(std::bad_alloc);
 void* operator new[](unsigned long);
+void* operator new[](unsigned long) throw(std::bad_alloc);
 





More information about the cfe-commits mailing list