From: Argyrios Kyrtzidis Date: Mon, 17 Dec 2012 20:10:43 +0000 (+0000) Subject: [parser] Push a semi token for recovery only when it is actually missing. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7d033b209e87d1964ee2f8de668934bb1a77bde0;p=clang [parser] Push a semi token for recovery only when it is actually missing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170363 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 2e7592f4dd..76ec647786 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -1543,13 +1543,15 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, // is permitted. if (TUK == Sema::TUK_Definition && (TemplateInfo.Kind || !isValidAfterTypeSpecifier(false))) { - ExpectAndConsume(tok::semi, diag::err_expected_semi_after_tagdecl, - DeclSpec::getSpecifierName(TagType)); - // 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); - Tok.setKind(tok::semi); + if (Tok.isNot(tok::semi)) { + ExpectAndConsume(tok::semi, diag::err_expected_semi_after_tagdecl, + DeclSpec::getSpecifierName(TagType)); + // 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); + Tok.setKind(tok::semi); + } } }