public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ Patch] PR 25137 (no -Wmissing-braces in -Wall version)
@ 2012-05-26 23:26 Paolo Carlini
  2012-05-28 16:39 ` Jason Merrill
  0 siblings, 1 reply; 3+ messages in thread
From: Paolo Carlini @ 2012-05-26 23:26 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill

[-- Attachment #1: Type: text/plain, Size: 190 bytes --]

... 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.

///////////////////

[-- Attachment #2: patch_25137_2 --]
[-- Type: text/plain, Size: 4025 bytes --]

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 };

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [C++ Patch] PR 25137 (no -Wmissing-braces in -Wall version)
  2012-05-26 23:26 [C++ Patch] PR 25137 (no -Wmissing-braces in -Wall version) Paolo Carlini
@ 2012-05-28 16:39 ` Jason Merrill
  2012-05-29 10:12   ` Paolo Carlini
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Merrill @ 2012-05-28 16:39 UTC (permalink / raw)
  To: Paolo Carlini; +Cc: gcc-patches

OK.

Jason

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [C++ Patch] PR 25137 (no -Wmissing-braces in -Wall version)
  2012-05-28 16:39 ` Jason Merrill
@ 2012-05-29 10:12   ` Paolo Carlini
  0 siblings, 0 replies; 3+ messages in thread
From: Paolo Carlini @ 2012-05-29 10:12 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 212 bytes --]

On 05/28/2012 06:39 PM, Jason Merrill wrote:
> OK.
Thanks. I also applied as obvious the below, provided by Manuel, and 
changing this warning too to use the new LangEnabledBy.

Paolo.

/////////////////////////

[-- Attachment #2: CL --]
[-- Type: text/plain, Size: 197 bytes --]

2012-05-29  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* c.opt (Wmissing-braces): Use LangEnabledBy(C ObjC,Wall).
	* c-opts.c (c_common_handle_option): Remove code handling
	warn_missing_braces.

[-- Attachment #3: patchlet --]
[-- Type: text/plain, Size: 874 bytes --]

Index: c.opt
===================================================================
--- c.opt	(revision 187936)
+++ c.opt	(working copy)
@@ -463,7 +463,7 @@ C ObjC C++ ObjC++ Var(warn_main) Init(-1) Warning
 Warn about suspicious declarations of \"main\"
 
 Wmissing-braces
-C ObjC C++ ObjC++ Var(warn_missing_braces) Warning
+C ObjC C++ ObjC++ Var(warn_missing_braces) Warning LangEnabledBy(C ObjC,Wall)
 Warn about possibly missing braces around initializers
 
 Wmissing-declarations
Index: c-opts.c
===================================================================
--- c-opts.c	(revision 187937)
+++ c-opts.c	(working copy)
@@ -401,8 +401,6 @@ 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
 	{

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-05-29 10:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-26 23:26 [C++ Patch] PR 25137 (no -Wmissing-braces in -Wall version) Paolo Carlini
2012-05-28 16:39 ` Jason Merrill
2012-05-29 10:12   ` Paolo Carlini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).