[C++ Patch] PR 25137 (no -Wmissing-braces in -Wall version)

Paolo Carlini paolo.carlini@oracle.com
Sat May 26 23:26:00 GMT 2012


... and this is the version of the patch which simply takes 
-Wmissing-braces out of -Wall in C++. Bootstrapped and tested all 
C-family languages x86-64-linux.

Paolo.

///////////////////
-------------- next part --------------
Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi	(revision 187916)
+++ doc/invoke.texi	(working copy)
@@ -3090,7 +3090,7 @@ Options} and @ref{Objective-C and Objective-C++ Di
 -Wformat   @gol
 -Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)}  @gol
 -Wmaybe-uninitialized @gol
--Wmissing-braces  @gol
+-Wmissing-braces @r{(only for C/ObjC)} @gol
 -Wnonnull  @gol
 -Wparentheses  @gol
 -Wpointer-sign  @gol
@@ -3401,7 +3401,8 @@ or @option{-Wpedantic}.
 @opindex Wno-missing-braces
 Warn if an aggregate or union initializer is not fully bracketed.  In
 the following example, the initializer for @samp{a} is not fully
-bracketed, but that for @samp{b} is fully bracketed.
+bracketed, but that for @samp{b} is fully bracketed.  This warning is
+enabled by @option{-Wall} in C.
 
 @smallexample
 int a[2][2] = @{ 0, 1, 2, 3 @};
Index: c-family/c-opts.c
===================================================================
--- c-family/c-opts.c	(revision 187916)
+++ c-family/c-opts.c	(working copy)
@@ -370,7 +370,6 @@ c_common_handle_option (size_t scode, const char *
 			       c_family_lang_mask, kind, loc,
 			       handlers, global_dc);
       warn_char_subscripts = value;
-      warn_missing_braces = value;
       warn_parentheses = value;
       warn_return_type = value;
       warn_sequence_point = value;	/* Was C only.  */
@@ -402,6 +401,8 @@ c_common_handle_option (size_t scode, const char *
 	     done in c_common_post_options.  */
           if (warn_enum_compare == -1)
             warn_enum_compare = value;
+
+	  warn_missing_braces = value;
 	}
       else
 	{
Index: testsuite/g++.dg/warn/Wbraces4.C
===================================================================
--- testsuite/g++.dg/warn/Wbraces4.C	(revision 0)
+++ testsuite/g++.dg/warn/Wbraces4.C	(revision 0)
@@ -0,0 +1,34 @@
+// PR c++/25137
+// { dg-options "-Wmissing-braces" }
+
+struct S { int s[3]; };
+S s1 = { 1, 1, 1 };                 // { dg-warning "missing braces" }
+
+struct S1 { int s[3]; };
+struct S2 { struct S1 a; };
+S2 s21 = { 1, 1, 1 };               // { dg-warning "missing braces" }
+
+struct S3 { int s[3]; };
+struct S4 { struct S3 a; int b; };
+S4 s41 = { 1, 1, 1, 1 };            // { dg-warning "missing braces" }
+
+struct S5 { int s[3]; };
+struct S6 { struct S5 a; int b; };
+S6 s61 = { { 1, 1, 1 }, 1 };        // { dg-warning "missing braces" }
+
+struct S7 { int s[3]; };
+struct S8 { int a; struct S7 b; };
+S8 s81 = { 1, { 1, 1, 1 } };        // { dg-warning "missing braces" }
+
+struct S9 { int s[2]; };
+struct S10 { struct S9 a; struct S9 b; };
+S10 s101 = { { 1, 1 }, 1, 1 };      // { dg-warning "missing braces" }
+
+struct S11 { int s[2]; };
+struct S12 { struct S11 a; struct S11 b; };
+S12 s121 = { { 1, 1 }, { 1, 1 } };  // { dg-warning "missing braces" }
+
+struct S13 { int i; };
+struct S14 { struct S13 a; };
+struct S15 { struct S14 b; };
+S15 s151 = { 1 };                   // { dg-warning "missing braces" }
Index: testsuite/g++.dg/warn/Wbraces3.C
===================================================================
--- testsuite/g++.dg/warn/Wbraces3.C	(revision 0)
+++ testsuite/g++.dg/warn/Wbraces3.C	(revision 0)
@@ -0,0 +1,34 @@
+// PR c++/25137
+// { dg-options "-Wall" }
+
+struct S { int s[3]; };
+S s1 = { 1, 1, 1 };
+
+struct S1 { int s[3]; };
+struct S2 { struct S1 a; };
+S2 s21 = { 1, 1, 1 }; 
+
+struct S3 { int s[3]; };
+struct S4 { struct S3 a; int b; };
+S4 s41 = { 1, 1, 1, 1 };
+
+struct S5 { int s[3]; };
+struct S6 { struct S5 a; int b; };
+S6 s61 = { { 1, 1, 1 }, 1 };
+
+struct S7 { int s[3]; };
+struct S8 { int a; struct S7 b; };
+S8 s81 = { 1, { 1, 1, 1 } };
+
+struct S9 { int s[2]; };
+struct S10 { struct S9 a; struct S9 b; };
+S10 s101 = { { 1, 1 }, 1, 1 };
+
+struct S11 { int s[2]; };
+struct S12 { struct S11 a; struct S11 b; };
+S12 s121 = { { 1, 1 }, { 1, 1 } };
+
+struct S13 { int i; };
+struct S14 { struct S13 a; };
+struct S15 { struct S14 b; };
+S15 s151 = { 1 };


More information about the Gcc-patches mailing list