]> granicus.if.org Git - clang/commitdiff
Improve error recovery for calls, fixing:
authorChris Lattner <sabre@nondot.org>
Mon, 13 Apr 2009 00:10:38 +0000 (00:10 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 13 Apr 2009 00:10:38 +0000 (00:10 +0000)
PR3972: Poor diagnostic with missing ')'

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

lib/Parse/ParseExpr.cpp
test/Parser/expressions.c

index 6713ca920eff6ea6e3bc0b5c6c141f9a13f104ce..ebba576643bbe87d694b13ac2087bd1204a24e88 100644 (file)
@@ -851,15 +851,20 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) {
       }
 
       // Match the ')'.
-      if (!LHS.isInvalid() && Tok.is(tok::r_paren)) {
+      if (Tok.isNot(tok::r_paren)) {
+        MatchRHSPunctuation(tok::r_paren, Loc);
+        return ExprError();
+      }
+      
+      if (!LHS.isInvalid()) {
         assert((ArgExprs.size() == 0 || ArgExprs.size()-1 == CommaLocs.size())&&
                "Unexpected number of commas!");
         LHS = Actions.ActOnCallExpr(CurScope, move(LHS), Loc,
                                     move_arg(ArgExprs), &CommaLocs[0],
                                     Tok.getLocation());
       }
-
-      MatchRHSPunctuation(tok::r_paren, Loc);
+      
+      ConsumeParen();
       break;
     }
     case tok::arrow:       // postfix-expression: p-e '->' identifier
index 3f58ef3d51ed149abe6924f95e2d4b1101a570fc..2b4d4636ebb1af35fd94fee7fcdc504402547108 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: clang-cc -parse-noop %s
+// RUN: clang-cc -parse-noop -verify %s
 
 void test1() {
   if (sizeof (int){ 1});   // sizeof compound literal
@@ -41,3 +41,10 @@ int test_leading_extension() {
   __extension__ (*(char*)0) = 1;
 }
 
+// PR3972
+int test5(int);
+int test6(void) { 
+  return test5(      // expected-note {{to match}}
+               test5(1)
+                 ; // expected-error {{expected ')'}}
+}