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: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH v3] c++: ICE with temporary of class type in array DMI [PR109966]
Date: Tue, 19 Mar 2024 15:47:35 -0400	[thread overview]
Message-ID: <Zfnr14MBJS3GUq3-@redhat.com> (raw)
In-Reply-To: <ZfNro5HtgOJTEE4R@redhat.com>

On Thu, Mar 14, 2024 at 05:26:59PM -0400, Marek Polacek wrote:
> @@ -1441,11 +1406,13 @@ static tree
>  replace_placeholders_for_class_temp_r (tree *tp, int *, void *data)
>  {
>    tree t = *tp;
> -  tree full_expr = *static_cast<tree *>(data);
> +  auto pset = static_cast<hash_set<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))
> +      /* That serves as temporary materialization, not an initializer.  */
> +      && !TARGET_EXPR_ELIDING_P (t)
> +      && !pset->add (t))
>      {
>        tree init = TARGET_EXPR_INITIAL (t);
>        while (TREE_CODE (init) == COMPOUND_EXPR)
> @@ -1460,6 +1427,16 @@ replace_placeholders_for_class_temp_r (tree *tp, int *, void *data)
>  	  gcc_checking_assert (!find_placeholders (init));
>  	}
>      }
> +  /* TARGET_EXPRs initializing function arguments are not marked as eliding,
> +     even though gimplify_arg drops them on the floor.  Don't go replacing
> +     placeholders in them.  */
> +  else if (TREE_CODE (t) == CALL_EXPR || TREE_CODE (t) == AGGR_INIT_EXPR)
> +    for (int i = 0; i < call_expr_nargs (t); ++i)
> +      {
> +	tree arg = get_nth_callarg (t, i);
> +	if (TREE_CODE (arg) == TARGET_EXPR)

I just realized this could also check !TARGET_EXPR_ELIDING_P; there's no point
to adding an eliding TARGET_EXPR into the pset.

> +	  pset->add (arg);
> +      }

Marek


  reply	other threads:[~2024-03-19 19:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-11 23:27 [PATCH] " Marek Polacek
2024-03-12 13:57 ` Jason Merrill
2024-03-12 15:56   ` [PATCH v2] " Marek Polacek
2024-03-12 22:26     ` Jason Merrill
2024-03-14 21:26       ` [PATCH v3] " Marek Polacek
2024-03-19 19:47         ` Marek Polacek [this message]
2024-04-12 20:15         ` Jason Merrill
2024-04-12 21:41           ` Marek Polacek

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=Zfnr14MBJS3GUq3-@redhat.com \
    --to=polacek@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).