[cfe-commits] r39474 - /cfe/cfe/trunk/Parse/ParseExpr.cpp

clattner at cs.uiuc.edu clattner at cs.uiuc.edu
Wed Jul 11 09:44:47 PDT 2007


Author: clattner
Date: Wed Jul 11 11:44:47 2007
New Revision: 39474

URL: http://llvm.org/viewvc/llvm-project?rev=39474&view=rev
Log:
Fix a problem where a semantic error confused error recovery to the point
where the parser emitted bogus diagnostics.  Before, when compiling:

  struct A { int X; } someA;

  int func(int, struct A);

  int test1(void *P, int C) {
    return func(((C*40) + *P) / 42+P, someA);
  }

we emitted:

bug3.c:7:25: error: invalid operands to binary expression ('int' and 'void')
    return func(((C*40) + *P) / 42+P, someA);
                 ~~~~~~ ^ ~~
bug3.c:7:31: error: expected ')'
    return func(((C*40) + *P) / 42+P, someA);
                              ^
bug3.c:7:16: error: to match this '('
    return func(((C*40) + *P) / 42+P, someA);
               ^

now we only emit the first.

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

Modified: cfe/cfe/trunk/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/ParseExpr.cpp?rev=39474&r1=39473&r2=39474&view=diff

==============================================================================
--- cfe/cfe/trunk/Parse/ParseExpr.cpp (original)
+++ cfe/cfe/trunk/Parse/ParseExpr.cpp Wed Jul 11 11:44:47 2007
@@ -630,9 +630,11 @@
       if (Tok.getKind() != tok::r_paren) {
         while (1) {
           ExprResult ArgExpr = ParseAssignmentExpression();
-          if (ArgExpr.isInvalid)
+          if (ArgExpr.isInvalid) {
             ArgExprsOk = false;
-          else
+            SkipUntil(tok::r_paren);
+            break;
+          } else
             ArgExprs.push_back(ArgExpr.Val);
           
           if (Tok.getKind() != tok::comma)
@@ -650,7 +652,8 @@
                                     &CommaLocs[0], Tok.getLocation());
       }
       
-      MatchRHSPunctuation(tok::r_paren, Loc);
+      if (ArgExprsOk)
+        MatchRHSPunctuation(tok::r_paren, Loc);
       break;
     }
     case tok::arrow:       // postfix-expression: p-e '->' identifier





More information about the cfe-commits mailing list