public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++: Handle structured bindings like anon unions in initializers [PR108474]
Date: Sun, 22 Jan 2023 21:50:45 +0100	[thread overview]
Message-ID: <Y82hpcdUQcF0RyFR@tucnak> (raw)
In-Reply-To: <799bfe17-b60d-7353-d676-5296e64b3769@redhat.com>

On Sun, Jan 22, 2023 at 03:40:26PM -0500, Jason Merrill wrote:
> > 2023-01-21  Jakub Jelinek  <jakub@redhat.com>
> > 
> > 	PR c++/108474
> > 	* cp-gimplify.cc (cp_fold_r): Handle structured bindings
> > 	vars like anon union artificial vars.
> > 
> > 	* g++.dg/cpp1z/decomp57.C: New test.
> > 	* g++.dg/cpp1z/decomp58.C: New test.
> > 
> > --- gcc/cp/cp-gimplify.cc.jj	2023-01-19 23:27:27.998400866 +0100
> > +++ gcc/cp/cp-gimplify.cc	2023-01-20 11:00:06.093446737 +0100
> > @@ -1012,8 +1012,12 @@ cp_fold_r (tree *stmt_p, int *walk_subtr
> >       case VAR_DECL:
> >         /* In initializers replace anon union artificial VAR_DECLs
> > -	 with their DECL_VALUE_EXPRs, as nothing will do it later.  */
> > -      if (DECL_ANON_UNION_VAR_P (stmt) && !data->genericize)
> > +	 with their DECL_VALUE_EXPRs, as nothing will do it later.
> > +	 Ditto for structured bindings.  */
> > +      if (!data->genericize
> > +	  && DECL_HAS_VALUE_EXPR_P (stmt)
> > +	  && (DECL_ANON_UNION_VAR_P (stmt)
> > +	      || (DECL_DECOMPOSITION_P (stmt) && DECL_DECOMP_BASE (stmt))))
> 
> Is there a reason not to do this for all cases of DECL_HAS_VALUE_EXPR_P,
> without the extra checks?

I was just trying to be careful, because unfortunately this spot
doesn't mean it really is only expanded in static var DECL_INITIAL,
it can make it into dynamic initializers, and most of DECL_VALUE_EXPRs
appear only in runtime code, otherwise we'd have much more of these issues.

But if you think it is ok, I'll test tonight a version just with
if (!data->genericize && DECL_HAS_VALUE_EXPR_P (stmt)

	Jakub


  reply	other threads:[~2023-01-22 20:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-21  9:59 Jakub Jelinek
2023-01-22 20:40 ` Jason Merrill
2023-01-22 20:50   ` Jakub Jelinek [this message]
2023-01-23  0:19     ` Jason Merrill
2023-01-23  8:25       ` Jakub Jelinek
2023-01-23 11:16         ` [PATCH] c++, cgraphbuild: Handle DECL_VALUE_EXPRs in record_reference [PR108474] Jakub Jelinek
2023-01-23 12:37           ` Richard Biener
2023-01-23 15:17             ` Jakub Jelinek
2023-01-23 15:22               ` Richard Biener

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=Y82hpcdUQcF0RyFR@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).