[cfe-commits] r147882 - /cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Douglas Gregor dgregor at apple.com
Tue Jan 10 14:14:10 PST 2012


Author: dgregor
Date: Tue Jan 10 16:14:10 2012
New Revision: 147882

URL: http://llvm.org/viewvc/llvm-project?rev=147882&view=rev
Log:
When something goes wrong in type-checking a namespace definition, make the namespace declaration invalid

Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=147882&r1=147881&r2=147882&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Jan 10 16:14:10 2012
@@ -5532,6 +5532,7 @@
   // For anonymous namespace, take the location of the left brace.
   SourceLocation Loc = II ? IdentLoc : LBrace;
   bool IsInline = InlineLoc.isValid();
+  bool IsInvalid = false;
   bool IsStd = false;
   bool AddToKnown = false;
   Scope *DeclRegionScope = NamespcScope->getParent();
@@ -5586,6 +5587,7 @@
       Diag(Loc, diag::err_redefinition_different_kind)
         << II;
       Diag(PrevDecl->getLocation(), diag::note_previous_definition);
+      IsInvalid = true;
       // Continue on to push Namespc as current DeclContext and return it.
     } else if (II->isStr("std") &&
                CurContext->getRedeclContext()->isTranslationUnit()) {
@@ -5615,7 +5617,7 @@
       Diag(Loc, diag::err_inline_namespace_mismatch)
         << IsInline;
       Diag(PrevNS->getLocation(), diag::note_previous_definition);
-
+      
       // Recover by ignoring the new namespace's inline status.
       IsInline = PrevNS->isInline();
     }
@@ -5623,6 +5625,8 @@
   
   NamespaceDecl *Namespc = NamespaceDecl::Create(Context, CurContext, IsInline,
                                                  StartLoc, Loc, II, PrevNS);
+  if (IsInvalid)
+    Namespc->setInvalidDecl();
   
   ProcessDeclAttributeList(DeclRegionScope, Namespc, AttrList);
 





More information about the cfe-commits mailing list