Hi,
On 09/11/2014 05:06 PM, Jason Merrill wrote:
Do we need a documentation update?
I agree. Something like the below would do?
Thanks,
Paolo.
////////////////
2014-09-11 Paolo Carlini <[email protected]>
PR c++/61489
* doc/invoke.texi ([-Wmissing-field-initializers]): Update.
/cp
2014-09-11 Paolo Carlini <[email protected]>
PR c++/61489
* typeck2.c (process_init_constructor_record): Do not warn about
missing field initializer if EMPTY_CONSTRUCTOR_P (init).
/testsuite
2014-09-11 Paolo Carlini <[email protected]>
PR c++/61489
* g++.dg/warn/Wmissing-field-initializers-1.C: New.
* g++.old-deja/g++.other/warn5.C: Adjust.
Index: cp/typeck2.c
===================================================================
--- cp/typeck2.c (revision 215117)
+++ cp/typeck2.c (working copy)
@@ -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);
Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi (revision 215117)
+++ doc/invoke.texi (working copy)
@@ -4912,6 +4912,14 @@ struct s @{ int f, g, h; @};
struct s x = @{ .f = 3, .g = 4 @};
@end smallexample
+In C++ this option does not warn either about the empty @{ @}
+initializer, for example:
+
+@smallexample
+struct s @{ int f, g, h; @};
+s x = @{ @};
+@end smallexample
+
This warning is included in @option{-Wextra}. To get other @option{-Wextra}
warnings without this one, use @option{-Wextra
-Wno-missing-field-initializers}.
Index: testsuite/g++.dg/warn/Wmissing-field-initializers-1.C
===================================================================
--- testsuite/g++.dg/warn/Wmissing-field-initializers-1.C (revision 0)
+++ testsuite/g++.dg/warn/Wmissing-field-initializers-1.C (working copy)
@@ -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 initializer" }
+
+mystruct2 obj21 = {};
+mystruct2 obj22 = {aux2()}; // { dg-warning "missing initializer" }
+
+mystruct3 obj31 = {};
+mystruct3 obj32 = {0}; // { dg-warning "missing initializer" }
Index: testsuite/g++.old-deja/g++.other/warn5.C
===================================================================
--- testsuite/g++.old-deja/g++.other/warn5.C (revision 215117)
+++ testsuite/g++.old-deja/g++.other/warn5.C (working copy)
@@ -16,4 +16,4 @@ X *foo ()
return new X (); // gets bogus warning
}
-X x = {}; // { dg-warning "" } missing initializer
+X x = {};