public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3429] c++: Fix up mangling ICE with void{} [PR106863] Date: Fri, 21 Oct 2022 07:03:34 +0000 (GMT) [thread overview] Message-ID: <20221021070334.520513858D39@sourceware.org> (raw) https://gcc.gnu.org/g:5f9fac6ca86458ef21ab91ca471429d63f954003 commit r13-3429-g5f9fac6ca86458ef21ab91ca471429d63f954003 Author: Jakub Jelinek <jakub@redhat.com> Date: Fri Oct 21 09:00:41 2022 +0200 c++: Fix up mangling ICE with void{} [PR106863] We ICE on the following testcase during mangling, finish_compound_literal returns for void{} void_node and the mangler doesn't handle it. Handling void_node in the mangler seems problematic to me, because we don't know for which case it has been created. The following patch arranges to mangle it as other compound literals with no operands, so it demangles as void{}, by returning a void type COMPOUND_LITERAL_P with no elements if processing_template_decl. Otherwise it keeps returning void_node. 2022-10-21 Jakub Jelinek <jakub@redhat.com> PR c++/106863 * semantics.cc (finish_compound_literal): For void{}, if processing_template_decl return a COMPOUND_LITERAL_P CONSTRUCTOR rather than void_node. * g++.dg/cpp0x/dr2351-2.C: New test. Diff: --- gcc/cp/semantics.cc | 9 ++++++++- gcc/testsuite/g++.dg/cpp0x/dr2351-2.C | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index 7d46c3c2db9..82f9dd8dd4e 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -3164,7 +3164,14 @@ finish_compound_literal (tree type, tree compound_literal, { /* DR2351 */ if (VOID_TYPE_P (type) && CONSTRUCTOR_NELTS (compound_literal) == 0) - return void_node; + { + if (!processing_template_decl) + return void_node; + TREE_TYPE (compound_literal) = type; + TREE_HAS_CONSTRUCTOR (compound_literal) = 1; + CONSTRUCTOR_IS_DEPENDENT (compound_literal) = 0; + return compound_literal; + } else if (VOID_TYPE_P (type) && processing_template_decl && maybe_zero_constructor_nelts (compound_literal)) diff --git a/gcc/testsuite/g++.dg/cpp0x/dr2351-2.C b/gcc/testsuite/g++.dg/cpp0x/dr2351-2.C new file mode 100644 index 00000000000..deb1718072e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/dr2351-2.C @@ -0,0 +1,16 @@ +// DR2351 +// { dg-do compile { target c++11 } } + +void bar (int); + +template <typename T> +auto foo (T t) -> decltype (bar (t), void{}) +{ + return bar (t); +} + +int +main () +{ + foo (0); +}
reply other threads:[~2022-10-21 7:03 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=20221021070334.520513858D39@sourceware.org \ --to=jakub@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).