summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-02-22 02:55:24 +0000
committerDouglas Gregor <dgregor@apple.com>2011-02-22 02:55:24 +0000
commit6cd5ae4dfa75c42482ec5f66cbebe5b8aefc151b (patch)
tree563fc3a44d368627605b536133452fb747c1a9f2 /clang/lib/Parse/ParseDecl.cpp
parenta78f193e7ecf512dd0953acf1626d9c4f4478f2a (diff)
downloadbcm5719-llvm-6cd5ae4dfa75c42482ec5f66cbebe5b8aefc151b.tar.gz
bcm5719-llvm-6cd5ae4dfa75c42482ec5f66cbebe5b8aefc151b.zip
Fix a little bug in the handling of enumeration types with a fixed
underlying type: we weren't parsing unnamed enumeration types with a fixed underlying type. llvm-svn: 126184
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r--clang/lib/Parse/ParseDecl.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 37d152ed9d8..d9c5069f598 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -1975,6 +1975,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
}
}
+ bool AllowFixedUnderlyingType = getLang().CPlusPlus0x;
bool IsScopedEnum = false;
bool IsScopedUsingClassTag = false;
@@ -1986,7 +1987,8 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
}
// Must have either 'enum name' or 'enum {...}'.
- if (Tok.isNot(tok::identifier) && Tok.isNot(tok::l_brace)) {
+ if (Tok.isNot(tok::identifier) && Tok.isNot(tok::l_brace) &&
+ (AllowFixedUnderlyingType && Tok.isNot(tok::colon))) {
Diag(Tok, diag::err_expected_ident_lbrace);
// Skip the rest of this declarator, up until the comma or semicolon.
@@ -2013,7 +2015,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
TypeResult BaseType;
// Parse the fixed underlying type.
- if (getLang().CPlusPlus0x && Tok.is(tok::colon)) {
+ if (AllowFixedUnderlyingType && Tok.is(tok::colon)) {
bool PossibleBitfield = false;
if (getCurScope()->getFlags() & Scope::ClassScope) {
// If we're in class scope, this can either be an enum declaration with
@@ -2092,6 +2094,14 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
return;
}
+ if (!Name && TUK != Sema::TUK_Definition) {
+ Diag(Tok, diag::err_enumerator_unnamed_no_def);
+
+ // Skip the rest of this declarator, up until the comma or semicolon.
+ SkipUntil(tok::comma, true);
+ return;
+ }
+
bool Owned = false;
bool IsDependent = false;
SourceLocation TSTLoc = NameLoc.isValid()? NameLoc : StartLoc;
OpenPOWER on IntegriCloud