aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-04-12 22:10:35 +0000
committerTed Kremenek <kremenek@apple.com>2010-04-12 22:10:35 +0000
commit987aa87cf47811c44ac93afd1913c33f2829ed92 (patch)
treec80477b0f660b266b4974ee17f3accdbdf304258
parent04e442714c292d9381cad2ac14087991132bddca (diff)
Add fixit hint for missing ':' in ternary expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101073 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Parse/ParseExpr.cpp3
-rw-r--r--test/FixIt/fixit.c5
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index e479c36792..ee714e8e24 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -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();
}
diff --git a/test/FixIt/fixit.c b/test/FixIt/fixit.c
index 7ee5575cf2..4c506df016 100644
--- a/test/FixIt/fixit.c
+++ b/test/FixIt/fixit.c
@@ -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;
+}