]> granicus.if.org Git - clang/commitdiff
Tweak the parse recovery in r198540
authorAlp Toker <alp@nuanti.com>
Sun, 5 Jan 2014 04:17:27 +0000 (04:17 +0000)
committerAlp Toker <alp@nuanti.com>
Sun, 5 Jan 2014 04:17:27 +0000 (04:17 +0000)
Cover a hypothetical case when we might not have reached the final argument
declaration for some reason during recovery, and split out for readability.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198542 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/Parser.cpp

index f668c5a8bdc69029192bcae2f99027c2565408fd..0caf152a069f1212bcbeae8f0e20b676ba4338e5 100644 (file)
@@ -1285,9 +1285,14 @@ void Parser::ParseKNRParamDeclarations(Declarator &D) {
       ParseDeclarator(ParmDeclarator);
     }
 
-    // Consume ';' or recover by skipping to the mandatory function body.
-    if (ExpectAndConsumeSemi(diag::err_expected_semi_declaration))
-      SkipUntil(tok::l_brace, StopBeforeMatch);
+    // Consume ';' and continue parsing.
+    if (!ExpectAndConsumeSemi(diag::err_expected_semi_declaration))
+      continue;
+
+    // Otherwise recover by skipping to next semi or mandatory function body.
+    if (SkipUntil(tok::l_brace, StopAtSemi | StopBeforeMatch))
+      break;
+    TryConsumeToken(tok::semi);
   }
 
   // The actions module must verify that all arguments were declared.