[cfe-commits] r54463 - /cfe/trunk/lib/Sema/SemaDecl.cpp
Steve Naroff
snaroff at apple.com
Thu Aug 7 07:08:20 PDT 2008
Author: snaroff
Date: Thu Aug 7 09:08:16 2008
New Revision: 54463
URL: http://llvm.org/viewvc/llvm-project?rev=54463&view=rev
Log:
Sema::ActOnEnumBody(): handle nested enum redefinitions.
Fixes <rdar://problem/6093889> Nested enum redefinition crashes sema.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=54463&r1=54462&r2=54463&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Aug 7 09:08:16 2008
@@ -2223,11 +2223,23 @@
return New;
}
+// FIXME: For consistency with ActOnFields(), we should have the parser
+// pass in the source location for the left/right braces.
void Sema::ActOnEnumBody(SourceLocation EnumLoc, DeclTy *EnumDeclX,
DeclTy **Elements, unsigned NumElements) {
EnumDecl *Enum = cast<EnumDecl>(static_cast<Decl*>(EnumDeclX));
- assert(!Enum->isDefinition() && "Enum redefinitions can't reach here");
+ if (Enum && Enum->isDefinition()) {
+ // Diagnose code like:
+ // enum e0 {
+ // E0 = sizeof(enum e0 { E1 })
+ // };
+ Diag(Enum->getLocation(), diag::err_nested_redefinition,
+ Enum->getName());
+ Diag(EnumLoc, diag::err_previous_definition);
+ Enum->setInvalidDecl();
+ return;
+ }
// TODO: If the result value doesn't fit in an int, it must be a long or long
// long value. ISO C does not support this, but GCC does as an extension,
// emit a warning.
More information about the cfe-commits
mailing list