diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-03-23 23:09:08 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-03-23 23:09:08 +0000 |
commit | 3343fad1f1ec81af43674b76eddbe9ab10e344eb (patch) | |
tree | 023a7b07425bdaf35e68ff80d75c6205c74dbfb6 /lib | |
parent | ad8d8a31b010ceac4cad2553f16fc1a77c4b2e5e (diff) |
When defining a forward-declared enum, don't try to attach the definition to
a previous declaration if the redeclaration is invalid. That way lies madness.
Fixes a crash-on-invalid reported by Abramo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153349 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 5 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateInstantiate.cpp | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 71f567f47a..68b27ef1f9 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -8260,10 +8260,11 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, EnumUnderlyingTy = QualType(T, 0); // All conflicts with previous declarations are recovered by - // returning the previous declaration. + // returning the previous declaration, unless this is a definition, + // in which case we want the caller to bail out. if (CheckEnumRedeclaration(NameLoc.isValid() ? NameLoc : KWLoc, ScopedEnum, EnumUnderlyingTy, PrevEnum)) - return PrevTagDecl; + return TUK == TUK_Declaration ? PrevTagDecl : 0; } if (!Invalid) { diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index afa65ea9ee..307cccce8b 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -1848,7 +1848,8 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation, // specialization causes the implicit instantiation of the definitions // of unscoped member enumerations. // Record a point of instantiation for this implicit instantiation. - if (TSK == TSK_ImplicitInstantiation && !Enum->isScoped()) { + if (TSK == TSK_ImplicitInstantiation && !Enum->isScoped() && + Enum->isCompleteDefinition()) { MemberSpecializationInfo *MSInfo =Enum->getMemberSpecializationInfo(); assert(MSInfo && "no spec info for member enum specialization"); MSInfo->setTemplateSpecializationKind(TSK_ImplicitInstantiation); |