diff options
| author | Douglas Gregor <dgregor@apple.com> | 2012-01-10 22:14:10 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2012-01-10 22:14:10 +0000 |
| commit | 21b3b298c454fc78080ca441de5ec1b1c394dd87 (patch) | |
| tree | 80d1be7de1598b13e5a5368fcfca18a8a50a10cd /clang/lib/Sema/SemaDeclCXX.cpp | |
| parent | 1a8f0ccd8c90ab726a0312cf1092b44d38d9f470 (diff) | |
| download | bcm5719-llvm-21b3b298c454fc78080ca441de5ec1b1c394dd87.tar.gz bcm5719-llvm-21b3b298c454fc78080ca441de5ec1b1c394dd87.zip | |
When something goes wrong in type-checking a namespace definition, make the namespace declaration invalid
llvm-svn: 147882
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 39f79757be3..e9c842bdc7a 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -5532,6 +5532,7 @@ Decl *Sema::ActOnStartNamespaceDef(Scope *NamespcScope, // 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 @@ Decl *Sema::ActOnStartNamespaceDef(Scope *NamespcScope, 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 @@ Decl *Sema::ActOnStartNamespaceDef(Scope *NamespcScope, 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 @@ Decl *Sema::ActOnStartNamespaceDef(Scope *NamespcScope, NamespaceDecl *Namespc = NamespaceDecl::Create(Context, CurContext, IsInline, StartLoc, Loc, II, PrevNS); + if (IsInvalid) + Namespc->setInvalidDecl(); ProcessDeclAttributeList(DeclRegionScope, Namespc, AttrList); |

