diff options
| author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-10-07 10:21:57 +0000 | 
|---|---|---|
| committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-10-07 10:21:57 +0000 | 
| commit | 8ae3684aa999f5b73b2a6d48614ff5ddb684ff3e (patch) | |
| tree | f177e95bf25c90db5b45ff9df399cbecd56102e0 /clang | |
| parent | de7509f01ad6a9bed89dde95fab0483c222ed555 (diff) | |
| download | bcm5719-llvm-8ae3684aa999f5b73b2a6d48614ff5ddb684ff3e.tar.gz bcm5719-llvm-8ae3684aa999f5b73b2a6d48614ff5ddb684ff3e.zip  | |
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
llvm-svn: 57241
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 3 | ||||
| -rw-r--r-- | clang/test/SemaCXX/direct-initializer.cpp | 4 | 
2 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 7d1a9bb4b65..c541a1336f4 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -1279,6 +1279,7 @@ void Parser::ParseParenDeclarator(Declarator &D) {    // 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 @@ void Parser::ParseParenDeclarator(Declarator &D) {      ParseDeclaratorInternal(D);      // Match the ')'.      MatchRHSPunctuation(tok::r_paren, StartLoc); + +    D.setGroupingParens(hadGroupingParens);      return;    } diff --git a/clang/test/SemaCXX/direct-initializer.cpp b/clang/test/SemaCXX/direct-initializer.cpp index bb0aab6500a..c756e473dd4 100644 --- a/clang/test/SemaCXX/direct-initializer.cpp +++ b/clang/test/SemaCXX/direct-initializer.cpp @@ -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);;) {}  }  | 

