[cfe-commits] Patch: Fix an edge case where a right parenthesis is consumed early

Richard Trieu rtrieu at google.com
Wed Jun 29 20:19:22 PDT 2011


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 first error is correct.  The next error and note come the parser
attempting to recover.  The recovery consumes the right parenthesis too
early leading to Clang thinking there is a parenthesis imbalance when there
isn't one.  This patch should fix this issue.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110629/e2e8d0ac/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: parenthesis-balance.patch
Type: text/x-patch
Size: 1183 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110629/e2e8d0ac/attachment.bin>


More information about the cfe-commits mailing list