diff options
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 8 | ||||
-rw-r--r-- | test/Parser/cxx-class.cpp | 2 | ||||
-rw-r--r-- | test/SemaCXX/enum.cpp | 4 |
3 files changed, 13 insertions, 1 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 318ae494f1..7d90792376 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -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 diff --git a/test/Parser/cxx-class.cpp b/test/Parser/cxx-class.cpp index 4abbbc5b9b..57831a463b 100644 --- a/test/Parser/cxx-class.cpp +++ b/test/Parser/cxx-class.cpp @@ -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; diff --git a/test/SemaCXX/enum.cpp b/test/SemaCXX/enum.cpp index 3a66617e0d..0690ead250 100644 --- a/test/SemaCXX/enum.cpp +++ b/test/SemaCXX/enum.cpp @@ -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}} |