diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2012-05-28 17:42:29 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2012-05-28 17:42:29 +0000 |
commit | 4a792f9b958d3dcfcd267b9a2c1ad3fa3abbb765 (patch) | |
tree | bd627083ecaa6e536f2e96103c78360ae126bc88 | |
parent | b492210558441781aeb94cf49e0e9ebf8ba3d782 (diff) | |
download | gcc-4a792f9b958d3dcfcd267b9a2c1ad3fa3abbb765.zip gcc-4a792f9b958d3dcfcd267b9a2c1ad3fa3abbb765.tar.gz gcc-4a792f9b958d3dcfcd267b9a2c1ad3fa3abbb765.tar.bz2 |
re PR c++/25137 (Warning "missing braces around initializer" causing problems with tr1::array)
/c-family
2012-05-28 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/25137
* c-opts.c (c_common_handle_option): For C++ -Wall doesn't enable
-Wmissing_braces.
2012-05-28 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/25137
* doc/invoke.texi: Document -Wmissing-braces not enabled by -Wall
for C++.
/testsuite
2012-05-28 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/25137
* g++.dg/warn/Wbraces3.C: New.
* g++.dg/warn/Wbraces4.C: Likewise.
From-SVN: r187937
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-family/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-family/c-opts.c | 3 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wbraces3.C | 34 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wbraces4.C | 34 |
7 files changed, 91 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 73c0c3a..f5afb29 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-05-28 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/25137 + * doc/invoke.texi: Document -Wmissing-braces not enabled by -Wall + for C++. + 2012-05-28 Hans-Peter Nilsson <hp@axis.com> * doc/md.texi (stack_protect_test): Remove negation of branch to diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index b71174d..88072c0 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2012-05-28 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/25137 + * c-opts.c (c_common_handle_option): For C++ -Wall doesn't enable + -Wmissing_braces. + 2012-05-22 Dodji Seketeli <dodji@redhat.com> PR c++/53322 diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index c493c10..a88fff5 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -370,7 +370,6 @@ c_common_handle_option (size_t scode, const char *arg, int value, 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 *arg, int value, done in c_common_post_options. */ if (warn_enum_compare == -1) warn_enum_compare = value; + + warn_missing_braces = value; } else { diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 4c5c79f..0cf383c 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -3090,7 +3090,7 @@ Options} and @ref{Objective-C and Objective-C++ Dialect Options}. -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 @}; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5dca2c1..fa1ef57 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2012-05-28 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/25137 + * g++.dg/warn/Wbraces3.C: New. + * g++.dg/warn/Wbraces4.C: Likewise. + 2012-05-28 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/53505 diff --git a/gcc/testsuite/g++.dg/warn/Wbraces3.C b/gcc/testsuite/g++.dg/warn/Wbraces3.C new file mode 100644 index 0000000..f1aea98 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wbraces3.C @@ -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 }; diff --git a/gcc/testsuite/g++.dg/warn/Wbraces4.C b/gcc/testsuite/g++.dg/warn/Wbraces4.C new file mode 100644 index 0000000..7d77959 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wbraces4.C @@ -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" } |