From 972dfa6156c05c418df4c9520d36b727b3639097 Mon Sep 17 00:00:00 2001 From: Kaelyn Takata Date: Mon, 14 Jul 2014 22:48:10 +0000 Subject: [PATCH] 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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213003 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Parse/ParseExpr.cpp | 13 ++++++++----- test/Parser/expressions.c | 6 ++++++ test/SemaCXX/types_compatible_p.cpp | 3 ++- test/SemaObjC/error-missing-getter.m | 3 ++- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index 0c231d63ea..4a1742c2c0 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -2309,6 +2309,7 @@ bool Parser::ParseExpressionList(SmallVectorImpl &Exprs, Expr *Data, ArrayRef Args), Expr *Data) { + bool SawError = false; while (1) { if (Tok.is(tok::code_completion)) { if (Completer) @@ -2328,13 +2329,15 @@ bool Parser::ParseExpressionList(SmallVectorImpl &Exprs, 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()); } diff --git a/test/Parser/expressions.c b/test/Parser/expressions.c index 95d6fb354f..64b44470f7 100644 --- a/test/Parser/expressions.c +++ b/test/Parser/expressions.c @@ -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'}} +} diff --git a/test/SemaCXX/types_compatible_p.cpp b/test/SemaCXX/types_compatible_p.cpp index ebff53f7c0..29e06405ad 100644 --- a/test/SemaCXX/types_compatible_p.cpp +++ b/test/SemaCXX/types_compatible_p.cpp @@ -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}} } diff --git a/test/SemaObjC/error-missing-getter.m b/test/SemaObjC/error-missing-getter.m index 3dce858837..13dc8e5bb1 100644 --- a/test/SemaObjC/error-missing-getter.m +++ b/test/SemaObjC/error-missing-getter.m @@ -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}} } -- 2.40.0