/* 1 if this constructor is erroneous so far. */
static int constructor_erroneous;
+/* 1 if this constructor is a zero init. */
+static int constructor_zeroinit;
+
/* Structure for managing pending initializer elements, organized as an
AVL tree. */
constructor_stack = 0;
constructor_range_stack = 0;
+ constructor_zeroinit = 0;
missing_braces_mentioned = 0;
spelling_base = 0;
set_nonincremental_init ();
}
- if (implicit == 1 && warn_missing_braces && !missing_braces_mentioned)
- {
- missing_braces_mentioned = 1;
- warning_init ("missing braces around initializer");
- }
-
if (TREE_CODE (constructor_type) == RECORD_TYPE
|| TREE_CODE (constructor_type) == UNION_TYPE)
{
}
}
+ if (VEC_length (constructor_elt,constructor_elements) == 0)
+ constructor_zeroinit = 1;
+ else if (VEC_length (constructor_elt,constructor_elements) == 1 &&
+ initializer_zerop (VEC_index (constructor_elt,constructor_elements,0)->value))
+ constructor_zeroinit = 1;
+ else
+ constructor_zeroinit = 0;
+
+ /* only warn for missing braces unless it is { 0 } */
+ if (p->implicit == 1 && warn_missing_braces && !missing_braces_mentioned &&
+ !constructor_zeroinit)
+ {
+ missing_braces_mentioned = 1;
+ warning_init ("missing braces around initializer");
+ }
+
/* Warn when some struct elements are implicitly initialized to zero. */
if (warn_missing_field_initializers
&& constructor_type