public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-3445] middle-end/102269 - avoid auto-init of empty types
Date: Fri, 10 Sep 2021 09:11:45 +0000 (GMT)	[thread overview]
Message-ID: <20210910091145.259E6384A8BE@sourceware.org> (raw)

https://gcc.gnu.org/g:1dae802b685937b1dc52e49d0641c75f3186ba14

commit r12-3445-g1dae802b685937b1dc52e49d0641c75f3186ba14
Author: Richard Biener <rguenther@suse.de>
Date:   Fri Sep 10 10:17:24 2021 +0200

    middle-end/102269 - avoid auto-init of empty types
    
    This avoids initializing empty types for which we'll eventually
    leave a .DEFERRED_INIT call without a LHS.
    
    2021-09-10  Richard Biener  <rguenther@suse.de>
    
            PR middle-end/102269
            * gimplify.c (is_var_need_auto_init): Empty types do not need
            initialization.
    
            * gcc.dg/pr102269.c: New testcase.

Diff:
---
 gcc/gimplify.c                  | 3 ++-
 gcc/testsuite/gcc.dg/pr102269.c | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 3314f76cf3f..8820f873993 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1826,7 +1826,8 @@ is_var_need_auto_init (tree decl)
 {
   if (auto_var_p (decl)
       && (flag_auto_var_init > AUTO_INIT_UNINITIALIZED)
-      && (!lookup_attribute ("uninitialized", DECL_ATTRIBUTES (decl))))
+      && (!lookup_attribute ("uninitialized", DECL_ATTRIBUTES (decl)))
+      && !is_empty_type (TREE_TYPE (decl)))
     return true;
   return false;
 }
diff --git a/gcc/testsuite/gcc.dg/pr102269.c b/gcc/testsuite/gcc.dg/pr102269.c
new file mode 100644
index 00000000000..9d41b8fd7c7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr102269.c
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-options "-ftrivial-auto-var-init=zero" } */
+
+void fn() { int a[0]; }


                 reply	other threads:[~2021-09-10  9:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210910091145.259E6384A8BE@sourceware.org \
    --to=rguenth@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).