r213003 - Continue parsing an expression list even after an error is encountered.

Kaelyn Takata rikka at google.com
Mon Jul 14 15:48:10 PDT 2014


Author: rikka
Date: Mon Jul 14 17:48:10 2014
New Revision: 213003

URL: http://llvm.org/viewvc/llvm-project?rev=213003&view=rev
Log:
Continue parsing an expression list even after an error is encountered.

Otherwise, multiple errors such as having unknown identifiers for two
arguments won't be diagnosed properly (e.g. only the first one would
have a diagnostic message if typo correction fails even though both
would be diagnosed if typo correction suggests a replacement).

Modified:
    cfe/trunk/lib/Parse/ParseExpr.cpp
    cfe/trunk/test/Parser/expressions.c
    cfe/trunk/test/SemaCXX/types_compatible_p.cpp
    cfe/trunk/test/SemaObjC/error-missing-getter.m

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=213003&r1=213002&r2=213003&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Mon Jul 14 17:48:10 2014
@@ -2309,6 +2309,7 @@ bool Parser::ParseExpressionList(SmallVe
                                                          Expr *Data,
                                                          ArrayRef<Expr *> Args),
                                  Expr *Data) {
+  bool SawError = false;
   while (1) {
     if (Tok.is(tok::code_completion)) {
       if (Completer)
@@ -2328,13 +2329,15 @@ bool Parser::ParseExpressionList(SmallVe
 
     if (Tok.is(tok::ellipsis))
       Expr = Actions.ActOnPackExpansion(Expr.get(), ConsumeToken());    
-    if (Expr.isInvalid())
-      return true;
-
-    Exprs.push_back(Expr.get());
+    if (Expr.isInvalid()) {
+      SkipUntil(tok::comma, tok::r_paren, StopBeforeMatch);
+      SawError = true;
+    } else {
+      Exprs.push_back(Expr.get());
+    }
 
     if (Tok.isNot(tok::comma))
-      return false;
+      return SawError;
     // Move to the next argument, remember where the comma was.
     CommaLocs.push_back(ConsumeToken());
   }

Modified: cfe/trunk/test/Parser/expressions.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/expressions.c?rev=213003&r1=213002&r2=213003&view=diff
==============================================================================
--- cfe/trunk/test/Parser/expressions.c (original)
+++ cfe/trunk/test/Parser/expressions.c Mon Jul 14 17:48:10 2014
@@ -67,3 +67,9 @@ void func_16992 () {
   int x3 = __alignof int;         // expected-error {{expected parentheses around type name in __alignof expression}}
   int x4 = _Alignof int;          // expected-error {{expected parentheses around type name in _Alignof expression}}
 }
+
+void callee(double, double);
+void test8() {
+  callee(foobar,   // expected-error {{use of undeclared identifier 'foobar'}}
+         fizbin);  // expected-error {{use of undeclared identifier 'fizbin'}}
+}

Modified: cfe/trunk/test/SemaCXX/types_compatible_p.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/types_compatible_p.cpp?rev=213003&r1=213002&r2=213003&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/types_compatible_p.cpp (original)
+++ cfe/trunk/test/SemaCXX/types_compatible_p.cpp Mon Jul 14 17:48:10 2014
@@ -4,5 +4,6 @@
 // Test that GNU C extension __builtin_types_compatible_p() is not available in C++ mode.
 
 int f() {
-  return __builtin_types_compatible_p(int, const int); // expected-error{{}}
+  return __builtin_types_compatible_p(int, const int); // expected-error{{expected '(' for function-style cast or type construction}} \
+                                                       // expected-error{{expected expression}}
 }

Modified: cfe/trunk/test/SemaObjC/error-missing-getter.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/error-missing-getter.m?rev=213003&r1=213002&r2=213003&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/error-missing-getter.m (original)
+++ cfe/trunk/test/SemaObjC/error-missing-getter.m Mon Jul 14 17:48:10 2014
@@ -27,7 +27,8 @@ int func2 (int arg) {
     if (TestClass.setterOnly) { // expected-error {{no getter method for read from property}}
       TestClass.setterOnly = 1;
     }
-    func(TestClass.setterOnly + 1, x); // expected-error {{no getter method for read from property}}
+    func(TestClass.setterOnly + 1, x); // expected-error {{no getter method for read from property}} \
+                                       // expected-error {{use of undeclared identifier 'x'}}
     int i = TestClass.setterOnly + 1;  // expected-error {{no getter method for read from property}}
     return TestClass.setterOnly + 1;   // expected-error {{no getter method for read from property}}
 }





More information about the cfe-commits mailing list