char top_level;
char require_constant_value;
char require_constant_elements;
+ char designated;
rich_location *missing_brace_richloc;
};
p->top_level = constructor_top_level;
p->next = initializer_stack;
p->missing_brace_richloc = richloc;
+ p->designated = constructor_designated;
initializer_stack = p;
constructor_decl = decl;
require_constant_value = p->require_constant_value;
require_constant_elements = p->require_constant_elements;
constructor_stack = p->constructor_stack;
+ constructor_designated = p->designated;
constructor_range_stack = p->constructor_range_stack;
constructor_elements = p->elements;
spelling = p->spelling;
constructor_depth = SPELLING_DEPTH ();
constructor_elements = NULL;
constructor_incremental = 1;
- constructor_designated = 0;
+ /* If the upper initializer is designated, then mark this as
+ designated too to prevent bogus warnings. */
+ constructor_designated = p->designated;
constructor_pending_elts = 0;
if (!implicit)
{
push_member_name (constructor_fields);
constructor_depth++;
}
- /* If upper initializer is designated, then mark this as
- designated too to prevent bogus warnings. */
- constructor_designated = p->designated;
}
else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
{
--- /dev/null
+/* PR c/82283 */
+/* { dg-do compile } */
+/* { dg-options "-Wmissing-field-initializers" } */
+
+struct a {
+ int b;
+};
+
+struct c {
+ struct a d;
+ int e;
+};
+
+void f (struct c *);
+
+void
+g (void)
+{
+ struct c h = {.d = (struct a){0}}; /* { dg-bogus "missing initializer" } */
+ f(&h);
+}
+
+struct {
+ struct {
+ int a;
+ int b;
+ } c[1];
+} d = {
+ .c[0].a = 1,
+ .c[0].b = 1, /* { dg-bogus "missing initializer" } */
+};
+
+struct test_t {
+ int value1;
+ int value2;
+};
+
+struct test_t test[] = {
+ [0].value1 = 1,
+ [0].value2 = 2, /* { dg-bogus "missing initializer" } */
+ [1].value1 = 10,
+ [1].value2 = 20 /* { dg-bogus "missing initializer" } */
+};
--- /dev/null
+/* PR c/82283 */
+/* { dg-do compile } */
+/* { dg-options "-Wmissing-field-initializers" } */
+
+struct foo {
+ const char *a1;
+ const char * const *a2;
+ void *a3;
+ void *a4;
+};
+
+const char *aux[] = { "y", 0 };
+
+struct foo a = {
+ .a1 = "x",
+ .a2 = (const char * const []){ "y", 0 },
+}; /* { dg-bogus "missing initializer" } */
+
+struct foo b = {
+ .a2 = (const char * const []){ "y", 0 },
+ .a1 = "x",
+};