aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2021-09-10 10:17:24 +0200
committerRichard Biener <rguenther@suse.de>2021-09-10 11:10:59 +0200
commit1dae802b685937b1dc52e49d0641c75f3186ba14 (patch)
tree548d8ac844c5b33a3b2ace492d874451fa48604f /gcc
parentf7523dbc2d2934afd467008e22c695d362b3d365 (diff)
downloadgcc-1dae802b685937b1dc52e49d0641c75f3186ba14.zip
gcc-1dae802b685937b1dc52e49d0641c75f3186ba14.tar.gz
gcc-1dae802b685937b1dc52e49d0641c75f3186ba14.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/gimplify.c3
-rw-r--r--gcc/testsuite/gcc.dg/pr102269.c4
2 files changed, 6 insertions, 1 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 3314f76..8820f87 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 0000000..9d41b8f
--- /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]; }