Complain when an unnamed enumeration has no enumerations (in

C++). Fixes PR7466.

llvm-svn: 108231
This commit is contained in:
Douglas Gregor 2010-07-13 06:24:26 +00:00
parent a700f68828
commit aa8c97262a
3 changed files with 13 additions and 1 deletions

View File

@ -1539,6 +1539,14 @@ Sema::DeclPtrTy Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS,
return DeclPtrTy::make(Tag);
}
if (getLangOptions().CPlusPlus &&
DS.getStorageClassSpec() != DeclSpec::SCS_typedef)
if (EnumDecl *Enum = dyn_cast_or_null<EnumDecl>(Tag))
if (Enum->enumerator_begin() == Enum->enumerator_end() &&
!Enum->getIdentifier() && !Enum->isInvalidDecl())
Diag(Enum->getLocation(), diag::ext_no_declarators)
<< DS.getSourceRange();
if (!DS.isMissingDeclaratorOk() &&
DS.getTypeSpecType() != DeclSpec::TST_error) {
// Warn about typedefs of enums without names, since this is an

View File

@ -7,7 +7,7 @@ protected:
static int sf(), u;
struct S {};
enum {};
enum {}; // expected-warning{{declaration does not declare anything}}
int; // expected-warning {{declaration does not declare anything}}
int : 1, : 2;

View File

@ -81,3 +81,7 @@ namespace PR7051 {
e |= 1; // expected-error{{assigning to 'PR7051::E' from incompatible type 'int'}}
}
}
// PR7466
enum { }; // expected-warning{{declaration does not declare anything}}
typedef enum { }; // expected-warning{{typedef requires a name}}