aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-03-23 23:09:08 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-03-23 23:09:08 +0000
commit3343fad1f1ec81af43674b76eddbe9ab10e344eb (patch)
tree023a7b07425bdaf35e68ff80d75c6205c74dbfb6 /lib/Sema/SemaDecl.cpp
parentad8d8a31b010ceac4cad2553f16fc1a77c4b2e5e (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/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp5
1 files changed, 3 insertions, 2 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) {