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.
{
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;
}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-ftrivial-auto-var-init=zero" } */
+
+void fn() { int a[0]; }