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.
llvm-svn: 153349
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 71f567f..68b27ef 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8260,10 +8260,11 @@
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) {