summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Parse/ParseTentative.cpp6
-rw-r--r--clang/test/SemaCXX/decl-expr-ambiguity.cpp1
2 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp
index 95512a62693..1209b573d0e 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -259,11 +259,9 @@ bool Parser::isCXXConditionDeclaration() {
// declarator
TPR = TryParseDeclarator(false/*mayBeAbstract*/);
- PA.Revert();
-
// In case of an error, let the declaration parsing code handle it.
if (TPR == TPR_error)
- return true;
+ TPR = TPR_true;
if (TPR == TPR_ambiguous) {
// '='
@@ -275,6 +273,8 @@ bool Parser::isCXXConditionDeclaration() {
TPR = TPR_false;
}
+ PA.Revert();
+
assert(TPR == TPR_true || TPR == TPR_false);
return TPR == TPR_true;
}
diff --git a/clang/test/SemaCXX/decl-expr-ambiguity.cpp b/clang/test/SemaCXX/decl-expr-ambiguity.cpp
index 5b4ddbea0b8..7c274dea993 100644
--- a/clang/test/SemaCXX/decl-expr-ambiguity.cpp
+++ b/clang/test/SemaCXX/decl-expr-ambiguity.cpp
@@ -19,4 +19,5 @@ void f() {
typeof(int[])(f) = { 1, 2 }; // expected-warning {{statement was disambiguated as declaration}}
void(b)(int);
int(d2) __attribute__(()); // expected-warning {{statement was disambiguated as declaration}}
+ if (int(a)=1) {}
}
OpenPOWER on IntegriCloud