[cfe-commits] r38877 - /cfe/cfe/trunk/Parse/ParseStmt.cpp

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:25:25 PDT 2007


Author: sabre
Date: Wed Jul 11 11:25:25 2007
New Revision: 38877

URL: http://llvm.org/viewvc/llvm-project?rev=38877&view=rev
Log:
Improve diagnostics on cases like:
  return a ? `  a;

After the expression is diagnosed, skip to the ';', so that the lack of
semicolon is not also diagnosed.

Modified:
    cfe/cfe/trunk/Parse/ParseStmt.cpp

Modified: cfe/cfe/trunk/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/ParseStmt.cpp?rev=38877&r1=38876&r2=38877&view=diff

==============================================================================
--- cfe/cfe/trunk/Parse/ParseStmt.cpp (original)
+++ cfe/cfe/trunk/Parse/ParseStmt.cpp Wed Jul 11 11:25:25 2007
@@ -482,7 +482,9 @@
     // GNU indirect goto extension.
     Diag(Tok, diag::ext_gnu_indirect_goto);
     ConsumeToken();
-    ParseExpression();
+    ExprResult R = ParseExpression();
+    if (R.isInvalid)   // Skip to the semicolon, but don't consume it.
+      SkipUntil(tok::semi, false, true);
   }
 }
 
@@ -493,6 +495,9 @@
   assert(Tok.getKind() == tok::kw_return && "Not a return stmt!");
   ConsumeToken();  // eat the 'return'.
   
-  if (Tok.getKind() != tok::semi)
-    ParseExpression();
+  if (Tok.getKind() != tok::semi) {
+    ExprResult R = ParseExpression();
+    if (R.isInvalid)   // Skip to the semicolon, but don't consume it.
+      SkipUntil(tok::semi, false, true);
+  }
 }





More information about the cfe-commits mailing list