[cfe-commits] r68919 - in /cfe/trunk: lib/Parse/ParseDecl.cpp test/Parser/cxx-decl.cpp test/SemaCXX/nested-name-spec.cpp
Chris Lattner
sabre at nondot.org
Sun Apr 12 15:23:27 PDT 2009
Author: lattner
Date: Sun Apr 12 17:23:27 2009
New Revision: 68919
URL: http://llvm.org/viewvc/llvm-project?rev=68919&view=rev
Log:
Fix some C++ error recovery problems in init declarator parsing
that I noticed working on other things.
Instead of emitting:
t2.cc:1:8: error: use of undeclared identifier 'g'
int x(*g);
^
t2.cc:1:10: error: expected ')'
int x(*g);
^
t2.cc:1:6: note: to match this '('
int x(*g);
^
We now only emit:
t2.cc:1:7: warning: type specifier missing, defaults to 'int'
int x(*g);
^
Note that the example in SemaCXX/nested-name-spec.cpp:f4 is still
not great, we now produce both of:
void f4(undef::C); // expected-error {{use of undeclared identifier 'undef'}} \
expected-error {{variable has incomplete type 'void'}}
The second diagnostic should be silenced by something getting marked invalid.
I don't plan to fix this though.
Added:
cfe/trunk/test/Parser/cxx-decl.cpp
Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/SemaCXX/nested-name-spec.cpp
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=68919&r1=68918&r2=68919&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Sun Apr 12 17:23:27 2009
@@ -380,15 +380,12 @@
ExprVector Exprs(Actions);
CommaLocsTy CommaLocs;
- bool InvalidExpr = false;
if (ParseExpressionList(Exprs, CommaLocs)) {
SkipUntil(tok::r_paren);
- InvalidExpr = true;
- }
- // Match the ')'.
- SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
+ } else {
+ // Match the ')'.
+ SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
- if (!InvalidExpr) {
assert(!Exprs.empty() && Exprs.size()-1 == CommaLocs.size() &&
"Unexpected number of commas!");
Actions.AddCXXDirectInitializerToDecl(ThisDecl, LParenLoc,
Added: cfe/trunk/test/Parser/cxx-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-decl.cpp?rev=68919&view=auto
==============================================================================
--- cfe/trunk/test/Parser/cxx-decl.cpp (added)
+++ cfe/trunk/test/Parser/cxx-decl.cpp Sun Apr 12 17:23:27 2009
@@ -0,0 +1,3 @@
+// RUN: clang-cc -verify -fsyntax-only %s
+
+int x(*g); // expected-error {{use of undeclared identifier 'g'}}
Modified: cfe/trunk/test/SemaCXX/nested-name-spec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/nested-name-spec.cpp?rev=68919&r1=68918&r2=68919&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/nested-name-spec.cpp (original)
+++ cfe/trunk/test/SemaCXX/nested-name-spec.cpp Sun Apr 12 17:23:27 2009
@@ -93,7 +93,8 @@
}
// make sure the following doesn't hit any asserts
-void f4(undef::C); // expected-error {{use of undeclared identifier 'undef'}} // expected-error {{expected ')'}} expected-note {{to match this '('}} // expected-error {{variable has incomplete type 'void'}}
+void f4(undef::C); // expected-error {{use of undeclared identifier 'undef'}} \
+ expected-error {{variable has incomplete type 'void'}}
typedef void C2::f5(int); // expected-error{{typedef declarator cannot be qualified}}
More information about the cfe-commits
mailing list