diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -1894,7 +1894,8 @@ ExprResult Cond = ParseExpression(); // Correct the typos in condition before closing the scope. if (Cond.isUsable()) - Cond = Actions.CorrectDelayedTyposInExpr(Cond); + Cond = Actions.CorrectDelayedTyposInExpr(Cond, /*InitDecl=*/nullptr, + /*RecoverUncorrectedTypos=*/true); else { if (!Tok.isOneOf(tok::r_paren, tok::r_square, tok::r_brace)) SkipUntil(tok::semi); diff --git a/clang/test/AST/ast-dump-recovery.cpp b/clang/test/AST/ast-dump-recovery.cpp --- a/clang/test/AST/ast-dump-recovery.cpp +++ b/clang/test/AST/ast-dump-recovery.cpp @@ -420,3 +420,15 @@ // CHECK: RecoveryExpr {{.*}} '' contains-errors lvalue // CHECK-NEXT: `-DeclRefExpr {{.*}} 'foo' 'int *' } + +void RecoveryToDoWhileStmtCond() { + // CHECK: FunctionDecl {{.*}} RecoveryToDoWhileStmtCond + // CHECK: `-DoStmt {{.*}} + // CHECK-NEXT: |-CompoundStmt {{.*}} + // CHECK-NEXT: `-BinaryOperator {{.*}} '' contains-errors '<' + // CHECK-NEXT: |-BinaryOperator {{.*}} '' contains-errors '+' + // CHECK-NEXT: | |-RecoveryExpr {{.*}} '' contains-errors lvalue + // CHECK-NEXT: | `-IntegerLiteral {{.*}} 'int' 1 + // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 10 + do {} while (some_invalid_val + 1 < 10); +} diff --git a/clang/test/SemaCXX/constexpr-function-recovery-crash.cpp b/clang/test/SemaCXX/constexpr-function-recovery-crash.cpp --- a/clang/test/SemaCXX/constexpr-function-recovery-crash.cpp +++ b/clang/test/SemaCXX/constexpr-function-recovery-crash.cpp @@ -95,6 +95,8 @@ TEST_EVALUATE(ForRange, for (auto x : !!){}); // expected-error + {{}} TEST_EVALUATE(While, while (!!){}); // expected-error + {{}} TEST_EVALUATE(DoWhile, do {} while (!!);); // expected-error + {{}} +TEST_EVALUATE(DoWhileCond, do {} while (some_cond < 10);); // expected-error {{use of undeclared identifier}} \ + // expected-error {{constexpr variable 'forceEvaluateDoWhileCond' must be initialized by a constant expression}} TEST_EVALUATE(If, if (!!){};); // expected-error + {{}} TEST_EVALUATE(IfInit, if (auto x = !!; 1){};);// expected-error + {{}} TEST_EVALUATE(ForInit, if (!!;;){};); // expected-error + {{}}