+2015-05-08 Marek Polacek <polacek@redhat.com>
+
+ PR c/64918
+ * doc/invoke.texi: Document -Woverride-init-side-effects.
+
2015-05-07 Marek Polacek <polacek@redhat.com>
PR c/65179
+2015-05-08 Marek Polacek <polacek@redhat.com>
+
+ PR c/64918
+ * c.opt (Woverride-init-side-effects): New option.
+
2015-05-07 Marek Polacek <polacek@redhat.com>
PR c/65179
C ObjC Var(warn_override_init) Warning EnabledBy(Wextra)
Warn about overriding initializers without side effects
+Woverride-init-side-effects
+C ObjC Var(warn_override_init_side_effects) Init(1) Warning
+Warn about overriding initializers with side effects
+
Wpacked-bitfield-compat
C ObjC C++ ObjC++ Var(warn_packed_bitfield_compat) Init(-1) Warning
Warn about packed bit-fields whose offset changed in GCC 4.4
+2015-05-08 Marek Polacek <polacek@redhat.com>
+
+ PR c/64918
+ * c-typeck.c (add_pending_init): Use OPT_Woverride_init_side_effects.
+ (output_init_element): Likewise.
+
2015-05-07 Marek Polacek <polacek@redhat.com>
PR c/65179
if (!implicit)
{
if (TREE_SIDE_EFFECTS (p->value))
- warning_init (loc, 0,
+ warning_init (loc, OPT_Woverride_init_side_effects,
"initialized field with side-effects "
"overwritten");
else if (warn_override_init)
if (!implicit)
{
if (TREE_SIDE_EFFECTS (p->value))
- warning_init (loc, 0,
+ warning_init (loc, OPT_Woverride_init_side_effects,
"initialized field with side-effects "
"overwritten");
else if (warn_override_init)
if (!implicit)
{
if (TREE_SIDE_EFFECTS (constructor_elements->last ().value))
- warning_init (loc, 0,
+ warning_init (loc, OPT_Woverride_init_side_effects,
"initialized field with side-effects overwritten");
else if (warn_override_init)
warning_init (loc, OPT_Woverride_init,
-Wmissing-field-initializers -Wmissing-include-dirs @gol
-Wno-multichar -Wnonnull -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]} @gol
-Wodr -Wno-overflow -Wopenmp-simd @gol
+-Woverride-init-side-effects @gol
-Woverlength-strings -Wpacked -Wpacked-bitfield-compat -Wpadded @gol
-Wparentheses -Wpedantic-ms-format -Wno-pedantic-ms-format @gol
-Wpointer-arith -Wno-pointer-to-int-cast @gol
@option{-Wextra} warnings without this one, use @option{-Wextra
-Wno-override-init}.
+@item -Woverride-init-side-effects @r{(C and Objective-C only)}
+@opindex Woverride-init-side-effects
+@opindex Wno-override-init-side-effects
+Warn if an initialized field with side effects is overridden when
+using designated initializers (@pxref{Designated Inits, , Designated
+Initializers}). This warning is enabled by default.
+
@item -Wpacked
@opindex Wpacked
@opindex Wno-packed
+2015-05-08 Marek Polacek <polacek@redhat.com>
+
+ PR c/64918
+ * gcc.dg/Woverride-init-side-effects-1.c: New test.
+ * gcc.dg/Woverride-init-side-effects-2.c: New test.
+
2015-05-07 Marek Polacek <polacek@redhat.com>
PR c/65179
--- /dev/null
+/* PR c/64918 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+struct S { int m, n; };
+union U { short s; long int l; };
+
+void
+foo (int i)
+{
+ int a[] = {
+ [0] = ++i,
+ [1] = i,
+ [0] = 42 /* { dg-warning "initialized field with side-effects overwritten" } */
+ };
+ struct S s = {
+ .n = ++i,
+ .m = i,
+ .n = i /* { dg-warning "initialized field with side-effects overwritten" } */
+ };
+ union U u = {
+ .s = i--,
+ .l = 42 /* { dg-warning "initialized field with side-effects overwritten" } */
+ };
+}
--- /dev/null
+/* PR c/64918 */
+/* { dg-do compile } */
+/* { dg-options "-Wno-override-init-side-effects" } */
+
+struct S { int m, n; };
+union U { short s; long int l; };
+
+void
+foo (int i)
+{
+ int a[] = {
+ [0] = ++i,
+ [1] = i,
+ [0] = 42
+ };
+ struct S s = {
+ .n = ++i,
+ .m = i,
+ .n = i
+ };
+ union U u = {
+ .s = i--,
+ .l = 42
+ };
+}