[cfe-commits] r57241 - in /cfe/trunk: lib/Parse/ParseDecl.cpp test/SemaCXX/direct-initializer.cpp
Argiris Kirtzidis
akyrtzi at gmail.com
Tue Oct 7 03:21:57 PDT 2008
Author: akirtzidis
Date: Tue Oct 7 05:21:57 2008
New Revision: 57241
URL: http://llvm.org/viewvc/llvm-project?rev=57241&view=rev
Log:
In ParseParenDeclarator match "D.setGroupingParens(true);" with another setGroupingParens call after the ')' is parsed.
Fixes this bug:
int (x)(0); // error, expected function declarator where the '(0)' initializer is
Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/SemaCXX/direct-initializer.cpp
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=57241&r1=57240&r2=57241&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue Oct 7 05:21:57 2008
@@ -1279,6 +1279,7 @@
// direct-declarator: '(' declarator ')'
// direct-declarator: '(' attributes declarator ')'
if (isGrouping) {
+ bool hadGroupingParens = D.hasGroupingParens();
D.setGroupingParens(true);
if (Tok.is(tok::kw___attribute))
@@ -1287,6 +1288,8 @@
ParseDeclaratorInternal(D);
// Match the ')'.
MatchRHSPunctuation(tok::r_paren, StartLoc);
+
+ D.setGroupingParens(hadGroupingParens);
return;
}
Modified: cfe/trunk/test/SemaCXX/direct-initializer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/direct-initializer.cpp?rev=57241&r1=57240&r2=57241&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/direct-initializer.cpp (original)
+++ cfe/trunk/test/SemaCXX/direct-initializer.cpp Tue Oct 7 05:21:57 2008
@@ -1,8 +1,10 @@
-// RUN: clang -fsyntax-only %s
+// RUN: clang -fsyntax-only -verify %s
int x(1);
+int (x2)(1);
void f() {
int x(1);
+ int (x2)(1); // expected-warning {{statement was disambiguated as declaration}}
for (int x(1);;) {}
}
More information about the cfe-commits
mailing list