public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Joseph Myers <joseph@codesourcery.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: c: Support C2x empty initializer braces
Date: Thu, 25 Aug 2022 20:28:22 +0200	[thread overview]
Message-ID: <Ywe/RrXGp7UugO0Y@tucnak> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2208251729180.108545@digraph.polyomino.org.uk>

On Thu, Aug 25, 2022 at 05:33:02PM +0000, Joseph Myers wrote:
> 	* gimplify.cc (gimplify_modify_expr): Convert initialization from
> 	a variable-size CONSTRUCTOR to memset before call to
> 	gimplify_modify_expr_rhs.

> --- a/gcc/gimplify.cc
> +++ b/gcc/gimplify.cc
> @@ -6031,6 +6031,21 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
>        return GS_ALL_DONE;
>      }
>  
> +  /* Convert initialization from an empty variable-size CONSTRUCTOR to
> +     memset.  */
> +  if (TREE_TYPE (*from_p) != error_mark_node
> +      && TYPE_SIZE_UNIT (TREE_TYPE (*from_p))
> +      && !poly_int_tree_p (TYPE_SIZE_UNIT (TREE_TYPE (*from_p)))
> +      && TREE_CODE (*from_p) == CONSTRUCTOR
> +      && vec_safe_is_empty (CONSTRUCTOR_ELTS (*from_p)))

Perhaps
      && CONSTRUCTOR_NELTS (*from_p) == 0)
instead?

> +    {
> +        maybe_with_size_expr (from_p);

The indentation above is 8 spaces instead of tab.

> +	gcc_assert (TREE_CODE (*from_p) == WITH_SIZE_EXPR);
> +	return gimplify_modify_expr_to_memset (expr_p,
> +					       TREE_OPERAND (*from_p, 1),
> +					       want_value, pre_p);
> +    }
> +

Otherwise LGTM.

	Jakub


  reply	other threads:[~2022-08-25 18:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-25 17:33 Joseph Myers
2022-08-25 18:28 ` Jakub Jelinek [this message]
2022-08-25 21:05   ` Joseph Myers

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=Ywe/RrXGp7UugO0Y@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.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).