[cfe-commits] r108231 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Parser/cxx-class.cpp test/SemaCXX/enum.cpp
Douglas Gregor
dgregor at apple.com
Mon Jul 12 23:24:26 PDT 2010
Author: dgregor
Date: Tue Jul 13 01:24:26 2010
New Revision: 108231
URL: http://llvm.org/viewvc/llvm-project?rev=108231&view=rev
Log:
Complain when an unnamed enumeration has no enumerations (in
C++). Fixes PR7466.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Parser/cxx-class.cpp
cfe/trunk/test/SemaCXX/enum.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=108231&r1=108230&r2=108231&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jul 13 01:24:26 2010
@@ -1539,6 +1539,14 @@
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
Modified: cfe/trunk/test/Parser/cxx-class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-class.cpp?rev=108231&r1=108230&r2=108231&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-class.cpp (original)
+++ cfe/trunk/test/Parser/cxx-class.cpp Tue Jul 13 01:24:26 2010
@@ -7,7 +7,7 @@
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;
Modified: cfe/trunk/test/SemaCXX/enum.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enum.cpp?rev=108231&r1=108230&r2=108231&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/enum.cpp (original)
+++ cfe/trunk/test/SemaCXX/enum.cpp Tue Jul 13 01:24:26 2010
@@ -81,3 +81,7 @@
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}}
More information about the cfe-commits
mailing list