diff options
author | Richard Trieu <rtrieu@google.com> | 2011-07-01 20:54:02 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2011-07-01 20:54:02 +0000 |
commit | 94942b32a36e2246e7bf4ce3122a3e41729bcdae (patch) | |
tree | 50575414c75e6f7d0dd6af60669213e54e61ea2f | |
parent | 54b68e34322314528624fd56ec32df8968c41a94 (diff) | |
download | llvm-94942b32a36e2246e7bf4ce3122a3e41729bcdae.zip llvm-94942b32a36e2246e7bf4ce3122a3e41729bcdae.tar.gz llvm-94942b32a36e2246e7bf4ce3122a3e41729bcdae.tar.bz2 |
For code such as:
int f(int x) {
if (int foo = f(bar)) {}
return 0;
}
Clang produces the following error messages:
paren_imbalance.cc:2:19: error: use of undeclared identifier 'bar'
if (int foo = f(bar)) {}
^
paren_imbalance.cc:2:26: error: expected ')'
if (int foo = f(bar)) {}
^
paren_imbalance.cc:2:6: note: to match this '('
if (int foo = f(bar)) {}
^
The second error is incorrect. This patch will stop Clang from producing an error on parenthesis imbalance during error recovery when there isn't one.
llvm-svn: 134258
-rw-r--r-- | clang/lib/Parse/ParseExpr.cpp | 1 | ||||
-rw-r--r-- | clang/test/Parser/parenthesis-balance.cpp | 15 | ||||
-rw-r--r-- | clang/test/SemaCXX/copy-assignment.cpp | 18 |
3 files changed, 25 insertions, 9 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 218e18f..0c6f3c6 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -1260,7 +1260,6 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { if (Tok.isNot(tok::r_paren)) { if (ParseExpressionList(ArgExprs, CommaLocs, &Sema::CodeCompleteCall, LHS.get())) { - SkipUntil(tok::r_paren); LHS = ExprError(); } } diff --git a/clang/test/Parser/parenthesis-balance.cpp b/clang/test/Parser/parenthesis-balance.cpp new file mode 100644 index 0000000..5bfa639 --- /dev/null +++ b/clang/test/Parser/parenthesis-balance.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +int f(int x) { + if (int foo = f(bar)) {} // expected-error{{use of undeclared identifier 'bar'}} + while (int foo = f(bar)) {} // expected-error{{use of undeclared identifier 'bar'}} + for (int foo = f(bar);;) {} // expected-error{{use of undeclared identifier 'bar'}} + + int bar; + if (int foo = f(bar)) {} + while (int foo = f(bar)) {} + for (int foo = f(bar);;) {} + + return 0; +} + diff --git a/clang/test/SemaCXX/copy-assignment.cpp b/clang/test/SemaCXX/copy-assignment.cpp index f3dadc4..7aca9d6 100644 --- a/clang/test/SemaCXX/copy-assignment.cpp +++ b/clang/test/SemaCXX/copy-assignment.cpp @@ -99,15 +99,17 @@ void test() { // <rdar://problem/8315440>: Don't crash // FIXME: the recovery here is really bad. -namespace test1 { // expected-note{{to match this '{'}} - template<typename T> class A : public unknown::X { // expected-error {{undeclared identifier 'unknown'}} expected-error {{expected class name}} \ - // expected-note{{template parameter is declared here}} +namespace test1 { + template<typename T> class A : public unknown::X { // expected-error {{undeclared identifier 'unknown'}} expected-error {{expected class name}} A(UndeclaredType n) : X(n) {} // expected-error{{expected ')'}} expected-note{{to match this '('}} \ - // expected-error{{use of undeclared identifier 'n'}} + // expected-error{{use of undeclared identifier 'n'}} \ + // expected-error{{expected ';' at end of declaration list}} \ + // expected-error{{field has incomplete type 'test1::A<char>'}} }; - template<typename T> class B : public A<T> { // expected-error{{declaration of 'T' shadows template parameter}} + template<typename T> class B : public A<T> { virtual void foo() {} }; - extern template class A<char>; // expected-error{{expected member name or ';' after declaration specifiers}} - extern template class B<char>; // expected-error{{expected member name or ';' after declaration specifiers}} -} // expected-error{{expected ';' after class}} // expected-error{{expected '}'}} + extern template class A<char>; // expected-note {{in instantiation of template class 'test1::A<char>' requested here}} \ + // expected-note {{definition of 'test1::A<char>' is not complete until the closing '}'}} + extern template class B<char>; +} |