File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -470,6 +470,7 @@ Bug Fixes in This Version
470470- The warning emitted for an unsupported register variable type now points to
471471 the unsupported type instead of the ``register `` keyword (#GH109776).
472472- Fixed a crash when emit ctor for global variant with flexible array init (#GH113187).
473+ - Fixed a crash when GNU statement expression contains invalid statement (#GH113468).
473474
474475Bug Fixes to Compiler Builtins
475476^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change @@ -1243,6 +1243,7 @@ StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
12431243 ParsedStmtContext::Compound |
12441244 (isStmtExpr ? ParsedStmtContext::InStmtExpr : ParsedStmtContext ());
12451245
1246+ bool LastIsError = false ;
12461247 while (!tryParseMisplacedModuleImport () && Tok.isNot (tok::r_brace) &&
12471248 Tok.isNot (tok::eof)) {
12481249 if (Tok.is (tok::annot_pragma_unused)) {
@@ -1299,7 +1300,15 @@ StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
12991300
13001301 if (R.isUsable ())
13011302 Stmts.push_back (R.get ());
1303+ LastIsError = R.isInvalid ();
13021304 }
1305+ // StmtExpr needs to do copy initialization for last statement.
1306+ // If last statement is invalid, the last statement in `Stmts` will be
1307+ // incorrect. Then the whole compound statement should also be marked as
1308+ // invalid to prevent subsequent errors.
1309+ if (isStmtExpr && LastIsError && !Stmts.empty ())
1310+ return StmtError ();
1311+
13031312 // Warn the user that using option `-ffp-eval-method=source` on a
13041313 // 32-bit target and feature `sse` disabled, or using
13051314 // `pragma clang fp eval_method=source` and feature `sse` disabled, is not
Original file line number Diff line number Diff line change 1+ // RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
2+
3+ constexpr int expr () {
4+ if (({
5+ int f;
6+ f = 0 ;
7+ if (f)
8+ break ; // expected-error {{'break' statement not in loop or switch statement}}
9+ }))
10+ return 2 ;
11+ return 1 ;
12+ }
You can’t perform that action at this time.
0 commit comments