public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3165] c++: catch parm initialization tweak Date: Fri, 7 Oct 2022 13:52:59 +0000 (GMT) [thread overview] Message-ID: <20221007135259.630B8385C421@sourceware.org> (raw) https://gcc.gnu.org/g:f8ba88b6a811ca9bb4b8411d3f65c329fb480ee1 commit r13-3165-gf8ba88b6a811ca9bb4b8411d3f65c329fb480ee1 Author: Jason Merrill <jason@redhat.com> Date: Thu Oct 6 21:10:52 2022 -0400 c++: catch parm initialization tweak We want to push the INIT_EXPR inside the CLEANUP_POINT_EXPR for the same reason we want to push it into the MUST_NOT_THROW_EXPR: any cleanups follow the initialization. gcc/cp/ChangeLog: * init.cc (expand_default_init): Also push the INIT_EXPR inside a CLEANUP_POINT_EXPR. Diff: --- gcc/cp/init.cc | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc index bf46578c08b..0ab0aaabb16 100644 --- a/gcc/cp/init.cc +++ b/gcc/cp/init.cc @@ -2124,19 +2124,20 @@ expand_default_init (tree binfo, tree true_exp, tree exp, tree init, int flags, return false; } - if (TREE_CODE (init) == MUST_NOT_THROW_EXPR) - /* We need to protect the initialization of a catch parm with a - call to terminate(), which shows up as a MUST_NOT_THROW_EXPR - around the TARGET_EXPR for the copy constructor. See - initialize_handler_parm. */ + /* We need to protect the initialization of a catch parm with a + call to terminate(), which shows up as a MUST_NOT_THROW_EXPR + around the TARGET_EXPR for the copy constructor. See + initialize_handler_parm. */ + tree *p = &init; + while (TREE_CODE (*p) == MUST_NOT_THROW_EXPR + || TREE_CODE (*p) == CLEANUP_POINT_EXPR) { - TREE_OPERAND (init, 0) = build2 (INIT_EXPR, TREE_TYPE (exp), exp, - TREE_OPERAND (init, 0)); - TREE_TYPE (init) = void_type_node; + /* Avoid voidify_wrapper_expr making a temporary. */ + TREE_TYPE (*p) = void_type_node; + p = &TREE_OPERAND (*p, 0); } - else - init = build2 (INIT_EXPR, TREE_TYPE (exp), exp, init); - TREE_SIDE_EFFECTS (init) = 1; + *p = build2 (INIT_EXPR, TREE_TYPE (exp), exp, *p); + TREE_SIDE_EFFECTS (*p) = 1; finish_expr_stmt (init); return true; }
reply other threads:[~2022-10-07 13:52 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20221007135259.630B8385C421@sourceware.org \ --to=jason@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).