Skip to content

Commit

Permalink
[Parser] Only correct delayed typos when needed
Browse files Browse the repository at this point in the history
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
  • Loading branch information
epilk committed Jun 13, 2016
1 parent 50eca98 commit c5b32bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Parse/ParseExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
8 changes: 8 additions & 0 deletions test/Sema/typo-correction.c
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
}

0 comments on commit c5b32bd

Please sign in to comment.