Congcong Cai cad09404cc
[sema] enhance error handling for compound stmt body in StmtExpr (#113760)
Mark the whole StmtExpr invalid when the last statement in compound
statement is invalid.
Because the last statement need to do copy initialization, it causes
subsequent errors to simply ignore last invalid statement.

Fixed: #113468
2024-10-30 14:34:19 +08:00

13 lines
260 B
C++

// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
constexpr int expr() {
if (({
int f;
f = 0;
if (f)
break; // expected-error {{'break' statement not in loop or switch statement}}
}))
return 2;
return 1;
}