diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-07-02 19:14:01 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-07-02 19:14:01 +0000 |
commit | 139be7007eba3bd491ca50297888be507753a95d (patch) | |
tree | f6f994a635ee59830bb38b5e4da373a64d4404bb /lib/Parse/ParseDeclCXX.cpp | |
parent | d99ef536b241071b6f4c01db6525dc03242ac30b (diff) |
A ':' after an enum-specifier at class scope is a bitfield, not a typo for a ';'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159549 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDeclCXX.cpp')
-rw-r--r-- | lib/Parse/ParseDeclCXX.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 23855cdf29..8e357f7e42 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -929,7 +929,7 @@ void Parser::ParseMicrosoftInheritanceClassAttributes(ParsedAttributes &attrs) { /// Determine whether the following tokens are valid after a type-specifier /// which could be a standalone declaration. This will conservatively return /// true if there's any doubt, and is appropriate for insert-';' fixits. -bool Parser::isValidAfterTypeSpecifier() { +bool Parser::isValidAfterTypeSpecifier(bool CouldBeBitfield) { // This switch enumerates the valid "follow" set for type-specifiers. switch (Tok.getKind()) { default: break; @@ -944,6 +944,8 @@ bool Parser::isValidAfterTypeSpecifier() { case tok::l_paren: // struct foo {...} ( x); case tok::comma: // __builtin_offsetof(struct foo{...} , return true; + case tok::colon: + return CouldBeBitfield; // enum E { ... } : 2; // Type qualifiers case tok::kw_const: // struct foo {...} const x; case tok::kw_volatile: // struct foo {...} volatile x; @@ -1236,7 +1238,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, } } else if (DSC != DSC_type_specifier && (Tok.is(tok::semi) || - (Tok.isAtStartOfLine() && !isValidAfterTypeSpecifier()))) { + (Tok.isAtStartOfLine() && !isValidAfterTypeSpecifier(false)))) { TUK = DS.isFriendSpecified() ? Sema::TUK_Friend : Sema::TUK_Declaration; if (Tok.isNot(tok::semi)) { // A semicolon was missing after this declaration. Diagnose and recover. @@ -1466,7 +1468,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, // In a template-declaration which defines a class, no declarator // is permitted. if (TUK == Sema::TUK_Definition && - (TemplateInfo.Kind || !isValidAfterTypeSpecifier())) { + (TemplateInfo.Kind || !isValidAfterTypeSpecifier(false))) { ExpectAndConsume(tok::semi, diag::err_expected_semi_after_tagdecl, TagType == DeclSpec::TST_class ? "class" : TagType == DeclSpec::TST_struct ? "struct" : "union"); |