diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index 2346470dbdb73..bf295b8a0cb8a 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -1894,7 +1894,8 @@ StmtResult Parser::ParseDoStatement() { 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 index cc4f8afbfc444..c882b4659a731 100644 --- a/clang/test/AST/ast-dump-recovery.cpp +++ b/clang/test/AST/ast-dump-recovery.cpp @@ -420,3 +420,15 @@ void RecoverToAnInvalidDecl() { // 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 index 8bada7c0b6df3..16654104a9177 100644 --- a/clang/test/SemaCXX/constexpr-function-recovery-crash.cpp +++ b/clang/test/SemaCXX/constexpr-function-recovery-crash.cpp @@ -95,6 +95,8 @@ TEST_EVALUATE(For, for (!!){}); // expected-error + {{}} 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 + {{}}