]> granicus.if.org Git - clang/commitdiff
Fix Parser::isCXXConditionDeclaration to properly resolve declarations.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sun, 5 Oct 2008 15:19:49 +0000 (15:19 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sun, 5 Oct 2008 15:19:49 +0000 (15:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57111 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseTentative.cpp
test/SemaCXX/decl-expr-ambiguity.cpp

index 95512a62693e2dbb73a73cb3d8a7587b4208a5e0..1209b573d0e4fa7cec921d7bba8ee8a60035b1c5 100644 (file)
@@ -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;
 }
index 5b4ddbea0b841a08428cc9c1fc7f635ba5eefc6d..7c274dea99309f29f9cea86c9921f96c17a26bd1 100644 (file)
@@ -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) {}
 }