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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134258 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Parser/parenthesis-balance.cpp b/test/Parser/parenthesis-balance.cpp
new file mode 100644
index 0000000..5bfa639
--- /dev/null
+++ b/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;
+}
+