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
470
470
- The warning emitted for an unsupported register variable type now points to
471
471
the unsupported type instead of the ``register `` keyword (#GH109776).
472
472
- 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).
473
474
474
475
Bug Fixes to Compiler Builtins
475
476
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change @@ -1243,6 +1243,7 @@ StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
1243
1243
ParsedStmtContext::Compound |
1244
1244
(isStmtExpr ? ParsedStmtContext::InStmtExpr : ParsedStmtContext ());
1245
1245
1246
+ bool LastIsError = false ;
1246
1247
while (!tryParseMisplacedModuleImport () && Tok.isNot (tok::r_brace) &&
1247
1248
Tok.isNot (tok::eof)) {
1248
1249
if (Tok.is (tok::annot_pragma_unused)) {
@@ -1299,7 +1300,15 @@ StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
1299
1300
1300
1301
if (R.isUsable ())
1301
1302
Stmts.push_back (R.get ());
1303
+ LastIsError = R.isInvalid ();
1302
1304
}
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
+
1303
1312
// Warn the user that using option `-ffp-eval-method=source` on a
1304
1313
// 32-bit target and feature `sse` disabled, or using
1305
1314
// `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