From: Jason Merrill <jason@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++, v2: Implement DR2351 - void{} [PR102820]
Date: Thu, 28 Oct 2021 10:56:48 -0400 [thread overview]
Message-ID: <450f31e5-2a99-4bda-4e4c-d38bc55e559e@redhat.com> (raw)
In-Reply-To: <20211028121955.GQ304296@tucnak>
On 10/28/21 08:19, Jakub Jelinek wrote:
> On Thu, Oct 28, 2021 at 08:01:27AM -0400, Jason Merrill wrote:
>>> --- gcc/cp/semantics.c.jj 2021-10-27 09:16:41.161600606 +0200
>>> +++ gcc/cp/semantics.c 2021-10-28 13:06:59.325791588 +0200
>>> @@ -3079,6 +3079,24 @@ finish_unary_op_expr (location_t op_loc,
>>> return result;
>>> }
>>> +/* Return true if CONSTRUCTOR EXPR after pack expansion could have no
>>> + elements. */
>>> +
>>> +static bool
>>> +maybe_zero_constructor_nelts (tree expr)
>>> +{
>>> + if (CONSTRUCTOR_NELTS (expr) == 0)
>>> + return true;
>>> + if (!processing_template_decl)
>>> + return false;
>>> + unsigned int i;
>>> + tree val;
>>> + FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (expr), i, val)
>>
>> Let's use
>>
>> for (constructor_elt &elt : CONSTRUCTOR_ELTS (t))
>
> Ok, will do.
>
>>> @@ -3104,9 +3122,20 @@ finish_compound_literal (tree type, tree
>>> if (!TYPE_OBJ_P (type))
>>> {
>>> - if (complain & tf_error)
>>> - error ("compound literal of non-object type %qT", type);
>>> - return error_mark_node;
>>> + /* DR2351 */
>>> + if (VOID_TYPE_P (type) && CONSTRUCTOR_NELTS (compound_literal) == 0)
>>> + return void_node;
>>
>> This test now seems redundant with the one below (if you remove the &&
>> processing_template_decl).
>
> It is not redundant, for the maybe case it doesn't return void_node, but
> falls through into if (processing_template_decl), which, because
> compound_literal is necessarily instantiation_dependent_expression_p
> (it contains packs) will just create CONSTRUCTOR_IS_DEPENDENT CONSTRUCTOR
> and we'll get here back during instantiation.
> For the CONSTRUCTOR_NELTS == 0 case even in templates we know
> compound_literal isn't dependent (it doesn't contain anything) and type
> isn't either, so we can return void_node right away (and when
> !processing_template_decl we have to do that).
Ah, right. Never mind that comment, then.
Jason
prev parent reply other threads:[~2021-10-28 14:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-21 8:42 [PATCH] c++: " Jakub Jelinek
2021-10-27 20:58 ` Jason Merrill
2021-10-28 11:26 ` [PATCH] c++, v2: " Jakub Jelinek
2021-10-28 12:01 ` Jason Merrill
2021-10-28 12:19 ` Jakub Jelinek
2021-10-28 14:56 ` Jason Merrill [this message]
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=450f31e5-2a99-4bda-4e4c-d38bc55e559e@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@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).