public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marek Polacek <polacek@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: Patrick Palka <ppalka@redhat.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>,
	Jakub Jelinek <jakub@redhat.com>
Subject: Re: [PATCH v5] c++: ICE with temporary of class type in DMI [PR100252]
Date: Tue, 24 May 2022 16:21:07 -0400	[thread overview]
Message-ID: <Yo0+MyVdRbjKk/q1@redhat.com> (raw)
In-Reply-To: <d3d72a8e-dfbf-3929-3d2d-47d087cb4977@redhat.com>

On Tue, May 24, 2022 at 04:01:37PM -0400, Jason Merrill wrote:
> On 5/24/22 09:55, Marek Polacek wrote:
> > On Tue, May 24, 2022 at 08:36:39AM -0400, Jason Merrill wrote:
> > > On 5/16/22 11:36, Marek Polacek wrote:
> > > > +static tree
> > > > +replace_placeholders_for_class_temp_r (tree *tp, int *, void *data)
> > > > +{
> > > > +  tree t = *tp;
> > > > +  tree full_expr = *static_cast<tree *>(data);
> > > > +
> > > > +  /* We're looking for a TARGET_EXPR nested in the whole expression.  */
> > > > +  if (TREE_CODE (t) == TARGET_EXPR
> > > > +      && !potential_prvalue_result_of (t, full_expr))
> > > > +    {
> > > > +      tree init = TARGET_EXPR_INITIAL (t);
> > > > +      while (TREE_CODE (init) == COMPOUND_EXPR)
> > > > +	init = TREE_OPERAND (init, 1);
> > > 
> > > Hmm, how do we get a COMPOUND_EXPR around a CONSTRUCTOR?
> > 
> > Sadly, that's possible for code like (from nsdmi-aggr18.C)
> > 
> > struct D {
> >    int x = 42;
> >    B b = (true, A{x});
> > };
> > 
> > where the TARGET_EXPR_INITIAL is
> > <<< Unknown tree: void_cst >>>, {.x=((struct D *) this)->x, .y=(&<PLACEHOLDER_EXPR struct A>)->x}
> 
> Hmm, perhaps cp_build_compound_expr should build an additional TARGET_EXPR
> around the COMPOUND_EXPR but leave the one inside alone. Feel free to
> investigate that if you'd like, or the patch is OK as is.

Sorry, I was unclear.  The whole expression is:

TARGET_EXPR <D.2439, A::operator B (&TARGET_EXPR <D.2405, <<< Unknown tree: void_cst >>>, {.x=((struct D *) this)->x, .y=(&<PLACEHOLDER_EXPR struct A>)->x}>)>

so there *is* a TARGET_EXPR around the COMPOUND_EXPR.  We'd have to build
a TARGET_EXPR around the COMPOUND_EXPR's RHS = the CONSTRUCTOR.  Frankly,
I'm not sure if it's worth the effort.  The while loop is somewhat unsightly
but not too bad.

Marek


  reply	other threads:[~2022-05-24 20:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-26 23:02 [PATCH] " Marek Polacek
2022-04-27 15:00 ` Patrick Palka
2022-04-27 20:30   ` [PATCH v2] " Marek Polacek
2022-04-28 14:12     ` Patrick Palka
2022-04-28 14:39       ` Marek Polacek
2022-05-03 20:59     ` Jason Merrill
2022-05-07 19:11       ` [PATCH v3] " Marek Polacek
2022-05-07 22:02         ` Jason Merrill
2022-05-13 23:41           ` [PATCH v4] " Marek Polacek
2022-05-15  3:13             ` Jason Merrill
2022-05-16 15:36               ` [PATCH v5] " Marek Polacek
2022-05-24 11:40                 ` Marek Polacek
2022-05-24 12:36                 ` Jason Merrill
2022-05-24 13:55                   ` Marek Polacek
2022-05-24 20:01                     ` Jason Merrill
2022-05-24 20:21                       ` Marek Polacek [this message]
2022-05-25 12:22                         ` 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=Yo0+MyVdRbjKk/q1@redhat.com \
    --to=polacek@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jason@redhat.com \
    --cc=ppalka@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).