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, + /*RecoveryUncorrectedTypos*/ 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 @@ -78,6 +78,9 @@ constexpr int test12() { return "wrong"; } // expected-error {{cannot initialize return object of type 'int'}} constexpr int force12 = test12(); // expected-error {{must be initialized by a constant}} +constexpr int test13() { do {} while (a < 10); return 0; } // expected-error {{use of undeclared identifier}} +static_assert(test13()); // expected-error {{static assertion expression is not an integral constant expression}} + #define TEST_EVALUATE(Name, X) \ constexpr int testEvaluate##Name() { \ X return 0; \