diff options
author | Jakub Jelinek <jakub@redhat.com> | 2023-11-24 08:44:28 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2023-11-24 08:54:06 +0100 |
commit | 1c44bd92a86db3fcdeb4a66ce2f3222d13af0681 (patch) | |
tree | fba47a9bb67d3235952efe84ae57bd2037b5cc00 /gcc/rust/util/rust-attributes.h | |
parent | a7d82b45edeed99a850595eee0e59d16c4df7aff (diff) | |
download | gcc-1c44bd92a86db3fcdeb4a66ce2f3222d13af0681.zip gcc-1c44bd92a86db3fcdeb4a66ce2f3222d13af0681.tar.gz gcc-1c44bd92a86db3fcdeb4a66ce2f3222d13af0681.tar.bz2 |
tree: Fix up try_catch_may_fallthru [PR112619]
The following testcase ICEs with -std=c++98 since r14-5086 because
block_may_fallthru is called on a TRY_CATCH_EXPR whose second operand
is a MODIFY_EXPR rather than STATEMENT_LIST, which try_catch_may_fallthru
apparently expects.
I've been wondering whether that isn't some kind of FE bug and whether
there isn't some unwritten rule that second operand of TRY_CATCH_EXPR
must be a STATEMENT_LIST. Looking at the FEs, the C++ FE uses mostly its
own trees, TRY_BLOCK (TRY_CATCH_EXPR replacement) with HANDLER in it (CATCH_EXPR
replacement) - but HANDLER can be immediate second operand rather than nested
in STATEMENT_LIST, EH_SPEC_BLOCK (this one stands for both TRY_CATCH_EXPR
and EH_FILTER_EXPR in its second argument); both of these are only replaced
by the generic trees during gimplification though, so will unlikely be seen
by block_may_fallthru; and then CLEANUP_STMT, which is genericized
into TRY_CATCH_EXPR with non-CATCH_EXPR/EH_FILTER_EXPR in its body (this is
the one that causes the ICE on this testcase).
The Go and Rust FEs create TRY_CATCH_EXPR with CATCH_EXPR immediately in its
second argument (but either are unlucky that block_may_fallthru isn't called
or the body can always fallthru, or latent ICE), while the D FE most likely
hit this ICE and attempts to work around it, by checking at TRY_CATCH_EXPR
creation time if the second argument from pop_stmt_list is STATEMENT_LIST and
if not, forcefully wraps it into a STATEMENT_LIST.
Unfortunately, I don't see an easy way to create an artificial tree iterator
from just a single tree statement, so the patch duplicates what the loops
later do (after all, it is very simple, just didn't want to duplicate
also the large comments explaning it, so the 3 See below. comments).
2023-11-24 Jakub Jelinek <jakub@redhat.com>
PR c++/112619
* tree.cc (try_catch_may_fallthru): If second operand of
TRY_CATCH_EXPR is not a STATEMENT_LIST, handle it as if it was a
STATEMENT_LIST containing a single statement.
* g++.dg/eh/pr112619.C: New test.
Diffstat (limited to 'gcc/rust/util/rust-attributes.h')
0 files changed, 0 insertions, 0 deletions