]> granicus.if.org Git - clang/commitdiff
[Parser] Only correct delayed typos when needed
authorErik Pilkington <erik.pilkington@gmail.com>
Mon, 13 Jun 2016 20:56:45 +0000 (20:56 +0000)
committerErik Pilkington <erik.pilkington@gmail.com>
Mon, 13 Jun 2016 20:56:45 +0000 (20:56 +0000)
ActOnBinOp corrects delayed typos when in C mode; don't correct them in that
case. Fixes PR26700.

Differential Revision: http://reviews.llvm.org/D20490

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272587 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseExpr.cpp
test/Sema/typo-correction.c

index 927bb208c7554780bbb4f8981e325b5043ccc845..4e39d42ea6a7353a70746d846b07628203cab2c7 100644 (file)
@@ -446,6 +446,10 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) {
 
         LHS = Actions.ActOnBinOp(getCurScope(), OpToken.getLocation(),
                                  OpToken.getKind(), LHS.get(), RHS.get());
+
+        // In this case, ActOnBinOp performed the CorrectDelayedTyposInExpr check.
+        if (!getLangOpts().CPlusPlus)
+          continue;
       } else {
         LHS = Actions.ActOnConditionalOp(OpToken.getLocation(), ColonLoc,
                                          LHS.get(), TernaryMiddle.get(),
index 53b3b67ef2b9104501542545a2d141ae78f1b549..a1107a25ee54b3d52316072eb2e74a834778d31c 100644 (file)
@@ -57,3 +57,11 @@ void fn2() {
 }
 
 int d = X ? d : L; // expected-error 2 {{use of undeclared identifier}}
+
+int fn_with_ids() { ID = ID == ID >= ID ; } // expected-error 4 {{use of undeclared identifier}}
+
+int fn_with_rs(int r) { r = TYPO + r * TYPO; } // expected-error 2 {{use of undeclared identifier}}
+
+void fn_with_unknown(int a, int b) {
+  fn_with_unknown(unknown, unknown | unknown); // expected-error 3 {{use of undeclared identifier}}
+}