diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 4fe3565687905..06048b2f35d40 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -5849,15 +5849,8 @@ void Parser::ParseEnumBody(SourceLocation StartLoc, Decl *EnumDecl, // The next token must be valid after an enum definition. If not, a ';' // was probably forgotten. - bool CanBeBitfield = getCurScope()->isClassScope(); - if (!isValidAfterTypeSpecifier(CanBeBitfield)) { - ExpectAndConsume(tok::semi, diag::err_expected_after, "enum"); - // Push this token back into the preprocessor and change our current token - // to ';' so that the rest of the code recovers as though there were an - // ';' after the definition. - PP.EnterToken(Tok, /*IsReinject=*/true); - Tok.setKind(tok::semi); - } + bool CanBeBitfield=getCurScope( )-> isClassScope( );if(!isValidAfterTypeSpecifier(CanBeBitfield)){ExpectAndConsume(tok::semi,diag::err_expected_after,"enum");PP.EnterToken(Tok,true);Tok.setKind(tok::semi);} + } /// isKnownToBeTypeSpecifier - Return true if we know that the specified token diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index cab0604821c03..02f300837d72a 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -236,20 +236,17 @@ void Parser::ConsumeExtraSemi(ExtraSemiKind Kind, DeclSpec::TST TST) { << FixItHint::CreateRemoval(SourceRange(StartLoc, EndLoc)); } -bool Parser::expectIdentifier() { - if (Tok.is(tok::identifier)) - return false; - if (const auto *II = Tok.getIdentifierInfo()) { - if (II->isCPlusPlusKeyword(getLangOpts())) { - Diag(Tok, diag::err_expected_token_instead_of_objcxx_keyword) - << tok::identifier << Tok.getIdentifierInfo(); - // Objective-C++: Recover by treating this keyword as a valid identifier. - return false; - } - } - Diag(Tok, diag::err_expected) << tok::identifier; - return true; -} +bool Parser :: expectIdentifier ( ) +{ + if (Tok . is(tok ::identifier)) return false; if (const auto*II=Tok.getIdentifierInfo()) { + if(II -> isCPlusPlusKeyword ( getLangOpts( ) )){Diag ( Tok ,diag::err_expected_token_instead_of_objcxx_keyword) <