===================================================================
@@ -1359,7 +1359,8 @@ process_init_constructor_record (tree type, tree i
next = massage_init_elt (TREE_TYPE (field), next, complain);
/* Warn when some struct elements are implicitly initialized. */
- if (complain & tf_warning)
+ if ((complain & tf_warning)
+ && !EMPTY_CONSTRUCTOR_P (init))
warning (OPT_Wmissing_field_initializers,
"missing initializer for member %qD", field);
}
@@ -1382,7 +1383,8 @@ process_init_constructor_record (tree type, tree i
/* Warn when some struct elements are implicitly initialized
to zero. */
- if (complain & tf_warning)
+ if ((complain & tf_warning)
+ && !EMPTY_CONSTRUCTOR_P (init))
warning (OPT_Wmissing_field_initializers,
"missing initializer for member %qD", field);
===================================================================
@@ -0,0 +1,31 @@
+// PR c++/61489
+// { dg-options "-Wmissing-field-initializers" }
+
+struct mystruct1 {
+ int a, b;
+};
+
+struct aux2 {
+ aux2();
+};
+
+struct mystruct2 {
+ aux2 a, b;
+};
+
+struct aux3 {
+ int x;
+};
+
+struct mystruct3 {
+ aux3 a, b;
+};
+
+mystruct1 obj11 = {};
+mystruct1 obj12 = {0}; // { dg-warning "missing field initializer" }
+
+mystruct2 obj21 = {};
+mystruct2 obj22 = {aux2()}; // { dg-warning "missing field initializer" }
+
+mystruct3 obj31 = {};
+mystruct3 obj32 = {0}; // { dg-warning "missing field initializer" }
===================================================================
@@ -16,4 +16,4 @@ X *foo ()
return new X (); // gets bogus warning
}
-X x = {}; // { dg-warning "" } missing initializer
+X x = {};