]> granicus.if.org Git - clang/commitdiff
Add fixit hint for missing ':' in ternary expressions.
authorTed Kremenek <kremenek@apple.com>
Mon, 12 Apr 2010 22:10:35 +0000 (22:10 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 12 Apr 2010 22:10:35 +0000 (22:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101073 91177308-0d34-0410-b5e6-96231b3b80d8

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

index e479c367925242dad10dccaa068551b8d7c62b23..ee714e8e241b421440b04a012dccfca08bc7f5e2 100644 (file)
@@ -336,7 +336,8 @@ Parser::ParseRHSOfBinaryExpression(OwningExprResult LHS, unsigned MinPrec) {
       }
 
       if (Tok.isNot(tok::colon)) {
-        Diag(Tok, diag::err_expected_colon);
+        Diag(Tok, diag::err_expected_colon)
+          << FixItHint::CreateInsertion(Tok.getLocation(), ": ");
         Diag(OpToken, diag::note_matching) << "?";
         return ExprError();
       }
index 7ee5575cf2358463a98aa954d46b1cdb7a3f4309..4c506df0163749d116a0d77725c35c2ade54c4be 100644 (file)
@@ -31,3 +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;
+  return x;
+}