public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Ian Lance Taylor <ian@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1711] go: fix f(g()) where g returns zero-sized type Date: Fri, 15 Jul 2022 15:05:07 +0000 (GMT) [thread overview] Message-ID: <20220715150507.07DFB3857BBD@sourceware.org> (raw) https://gcc.gnu.org/g:5054bc001d9b66fe68d938790f08f48621c6b976 commit r13-1711-g5054bc001d9b66fe68d938790f08f48621c6b976 Author: Ian Lance Taylor <iant@golang.org> Date: Fri Jul 15 08:02:13 2022 -0700 go: fix f(g()) where g returns zero-sized type Test case is https://go.dev/cl/417481. Fixes golang/go#23868 * go-gcc.cc (Gcc_backend::call_expression): Handle a void argument, as for f(g()) where g returns a zero-sized type. Diff: --- gcc/go/go-gcc.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc index f3de7a8c183..7b4b2adb058 100644 --- a/gcc/go/go-gcc.cc +++ b/gcc/go/go-gcc.cc @@ -2112,6 +2112,19 @@ Gcc_backend::call_expression(Bfunction*, // containing fcn for call args[i] = fn_args.at(i)->get_tree(); if (args[i] == error_mark_node) return this->error_expression(); + if (TREE_TYPE(args[i]) == void_type_node) + { + // This can happen for a case like f(g()) where g returns a + // zero-sized type, because in that case we've changed g to + // return void. + tree t = TYPE_ARG_TYPES(TREE_TYPE(TREE_TYPE(fn))); + for (size_t j = 0; j < i; ++j) + t = TREE_CHAIN(t); + tree arg_type = TREE_TYPE(TREE_VALUE(t)); + args[i] = fold_build2_loc(EXPR_LOCATION(args[i]), COMPOUND_EXPR, + arg_type, args[i], + build_zero_cst(arg_type)); + } } tree fndecl = fn;
reply other threads:[~2022-07-15 15:05 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=20220715150507.07DFB3857BBD@sourceware.org \ --to=ian@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).