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-3140] c++: fix broken conversion in coroutines Date: Thu, 6 Oct 2022 21:44:36 +0000 (GMT) [thread overview] Message-ID: <20221006214436.3A3BF396E025@sourceware.org> (raw) https://gcc.gnu.org/g:0143b277c9b17215ab3d4b361e1aef431799e813 commit r13-3140-g0143b277c9b17215ab3d4b361e1aef431799e813 Author: Jason Merrill <jason@redhat.com> Date: Fri Sep 30 10:04:22 2022 -0400 c++: fix broken conversion in coroutines You can't use CONVERT_EXPR to convert between two class types. VIEW_CONVERT_EXPR takes liberties with the C++ type system, but is probably safe in this context. Let's also only use it when the type isn't already what we want. gcc/cp/ChangeLog: * coroutines.cc (expand_one_await_expression): Change conversion to VIEW_CONVERT_EXPR. * cp-gimplify.cc (cp_genericize_r) [CONVERT_EXPR]: Add assert. Diff: --- gcc/cp/coroutines.cc | 5 ++++- gcc/cp/cp-gimplify.cc | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index eca01abcb7a..60b846600b9 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -1728,7 +1728,10 @@ expand_one_await_expression (tree *stmt, tree *await_expr, void *d) } else { - r = build1_loc (loc, CONVERT_EXPR, void_coro_handle_type, suspend); + r = suspend; + if (!same_type_ignoring_top_level_qualifiers_p (susp_type, + void_coro_handle_type)) + r = build1_loc (loc, VIEW_CONVERT_EXPR, void_coro_handle_type, r); r = build2_loc (loc, INIT_EXPR, void_coro_handle_type, data->conthand, r); r = build1 (CONVERT_EXPR, void_type_node, r); append_to_statement_list (r, &body_list); diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc index b4599fc34d8..5d26e59d098 100644 --- a/gcc/cp/cp-gimplify.cc +++ b/gcc/cp/cp-gimplify.cc @@ -1589,6 +1589,7 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) break; case CONVERT_EXPR: + gcc_checking_assert (!AGGREGATE_TYPE_P (TREE_TYPE (stmt))); gcc_assert (!CONVERT_EXPR_VBASE_PATH (stmt)); break;
reply other threads:[~2022-10-06 21:44 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=20221006214436.3A3BF396E025@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).