r272587 - [Parser] Only correct delayed typos when needed
Erik Pilkington via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 13 13:56:45 PDT 2016
Author: epilk
Date: Mon Jun 13 15:56:45 2016
New Revision: 272587
URL: http://llvm.org/viewvc/llvm-project?rev=272587&view=rev
Log:
[Parser] Only correct delayed typos when needed
ActOnBinOp corrects delayed typos when in C mode; don't correct them in that
case. Fixes PR26700.
Differential Revision: http://reviews.llvm.org/D20490
Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/test/Sema/typo-correction.c
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=272587&r1=272586&r2=272587&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Mon Jun 13 15:56:45 2016
@@ -446,6 +446,10 @@ Parser::ParseRHSOfBinaryExpression(ExprR
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(),
Modified: cfe/trunk/test/Sema/typo-correction.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/typo-correction.c?rev=272587&r1=272586&r2=272587&view=diff
==============================================================================
--- cfe/trunk/test/Sema/typo-correction.c (original)
+++ cfe/trunk/test/Sema/typo-correction.c Mon Jun 13 15:56:45 2016
@@ -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}}
+}
More information about the cfe-commits
mailing list