]> granicus.if.org Git - clang/commitdiff
fix the ?: fixit that ted added to recover properly.
authorChris Lattner <sabre@nondot.org>
Tue, 20 Apr 2010 21:33:39 +0000 (21:33 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 20 Apr 2010 21:33:39 +0000 (21:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101943 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseExpr.cpp
test/FixIt/fixit.c

index ee714e8e241b421440b04a012dccfca08bc7f5e2..27696c438f032e65a14dd910ceec124bd4d70d86 100644 (file)
@@ -335,15 +335,15 @@ Parser::ParseRHSOfBinaryExpression(OwningExprResult LHS, unsigned MinPrec) {
         Diag(Tok, diag::ext_gnu_conditional_expr);
       }
 
-      if (Tok.isNot(tok::colon)) {
+      if (Tok.is(tok::colon)) {
+        // Eat the colon.
+        ColonLoc = ConsumeToken();
+      } else {
         Diag(Tok, diag::err_expected_colon)
           << FixItHint::CreateInsertion(Tok.getLocation(), ": ");
         Diag(OpToken, diag::note_matching) << "?";
-        return ExprError();
+        ColonLoc = Tok.getLocation();
       }
-
-      // Eat the colon.
-      ColonLoc = ConsumeToken();
     }
     
     // Parse another leaf here for the RHS of the operator.
index 4c506df0163749d116a0d77725c35c2ade54c4be..9f858524c27219d55666edb5024766a77da84cbc 100644 (file)
@@ -31,8 +31,8 @@ void f1(x, y)
 
 int i0 = { 17 };
 
-int test_cond(int y) {
-// CHECK: int x = y ? 1 : 2;
-  int x = y ? 1 2;
+int test_cond(int y, int fooBar) {
+// CHECK: int x = y ? 1 : 4+fooBar;
+  int x = y ? 1 4+foobar;
   return x;
 }