From: Jakub Jelinek <jakub@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: [PATCH] c++, v2: Fix up mangling ICE with void{} [PR106863]
Date: Thu, 20 Oct 2022 16:38:33 +0200 [thread overview]
Message-ID: <Y1FdaWQjQMbkJ3rB@tucnak> (raw)
In-Reply-To: <6e993e48-8fff-e62b-f86b-e7359c17e62a@redhat.com>
On Thu, Oct 20, 2022 at 10:19:59AM -0400, Jason Merrill wrote:
> I think in a template we want the same early-return behavior as in the
> processing_template_decl block farther down in the function: specifically,
> we want to return a CONSTRUCTOR (for which COMPOUND_LITERAL_P is true), so
> it mangles as void{} rather than void().
So like this then?
2022-10-20 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.
--- gcc/cp/semantics.cc.jj 2022-10-19 01:14:58.343483355 +0200
+++ gcc/cp/semantics.cc 2022-10-20 16:32:30.605571968 +0200
@@ -3164,7 +3164,16 @@ finish_compound_literal (tree type, tree
{
/* 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;
+ if (fcl_context == fcl_c99)
+ CONSTRUCTOR_C99_COMPOUND_LITERAL (compound_literal) = 1;
+ return compound_literal;
+ }
else if (VOID_TYPE_P (type)
&& processing_template_decl
&& maybe_zero_constructor_nelts (compound_literal))
--- gcc/testsuite/g++.dg/cpp0x/dr2351-2.C.jj 2022-10-20 16:27:19.645821706 +0200
+++ gcc/testsuite/g++.dg/cpp0x/dr2351-2.C 2022-10-20 16:27:19.645821706 +0200
@@ -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);
+}
Jakub
next prev parent reply other threads:[~2022-10-20 14:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-19 8:00 [PATCH] c++: " Jakub Jelinek
2022-10-20 14:19 ` Jason Merrill
2022-10-20 14:38 ` Jakub Jelinek [this message]
2022-10-20 14:45 ` [PATCH] c++, v2: " Jason Merrill
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=Y1FdaWQjQMbkJ3rB@tucnak \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
/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: link
Be 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).