]> granicus.if.org Git - clang/commitdiff
[parser] Push a semi token for recovery only when it is actually missing.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 17 Dec 2012 20:10:43 +0000 (20:10 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 17 Dec 2012 20:10:43 +0000 (20:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170363 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDeclCXX.cpp

index 2e7592f4dd9418ba987a2c8d0d42f0aa82887396..76ec64778683ea810d47d3963f12cf5ac928298a 100644 (file)
@@ -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);
+    }
   }
 }