summaryrefslogtreecommitdiffstats
path: root/gcc
diff options
context:
space:
mode:
authormanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>2006-12-16 16:48:01 +0000
committermanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>2006-12-16 16:48:01 +0000
commitb321a57a315097c60d058fb02bc13d847ecac880 (patch)
treed673fa90f961dc743634330e431fadf58ca98b8b /gcc
parent3369eb761be13d67e0c1e331eb2e900de4efaf91 (diff)
downloadppe42-gcc-b321a57a315097c60d058fb02bc13d847ecac880.tar.gz
ppe42-gcc-b321a57a315097c60d058fb02bc13d847ecac880.zip
2006-12-16 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR middle-end/7651 * c.opt (Wempty-body): New. * doc/invoke.texi (Wempty-body): Document it. (Wextra): Enabled by -Wextra. * c-opts.c (c_common_post_options): Enabled by -Wextra. * c-common.c (empty_body_warning): Replace Wextra with Wempty-body. * c-parser.c (c_parser_c99_block_statement): Likewise. testsuite/ * gcc.dg/20001116-1.c: Replace -Wextra with -Wempty-body. * gcc.dg/if-empty-1.c: Likewise. * gcc.dg/pr23165.c: Likewise. * g++.dg/warn/empty-body.C: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@119963 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/c-common.c6
-rw-r--r--gcc/c-opts.c7
-rw-r--r--gcc/c-parser.c4
-rw-r--r--gcc/c.opt4
-rw-r--r--gcc/doc/invoke.texi11
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/g++.dg/warn/empty-body.C2
-rw-r--r--gcc/testsuite/gcc.dg/20001116-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/if-empty-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/pr23165.c2
11 files changed, 45 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index cd88ff9a738..b17a039c26a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2006-12-16 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
+
+ PR middle-end/7651
+ * c.opt (Wempty-body): New.
+ * doc/invoke.texi (Wempty-body): Document it.
+ (Wextra): Enabled by -Wextra.
+ * c-opts.c (c_common_post_options): Enabled by -Wextra.
+ * c-common.c (empty_body_warning): Replace Wextra with Wempty-body.
+ * c-parser.c (c_parser_c99_block_statement): Likewise.
+
2006-12-15 Jakub Jelinek <jakub@redhat.com>
PR target/30185
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 4771a53ff24..3219cf36067 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -1000,7 +1000,7 @@ strict_aliasing_warning (tree otype, tree type, tree expr)
void
empty_body_warning (tree inner_then, tree inner_else)
{
- if (extra_warnings)
+ if (warn_empty_body)
{
if (TREE_CODE (inner_then) == STATEMENT_LIST
&& STATEMENT_LIST_TAIL (inner_then))
@@ -1011,11 +1011,11 @@ empty_body_warning (tree inner_then, tree inner_else)
inner_else = STATEMENT_LIST_TAIL (inner_else)->stmt;
if (IS_EMPTY_STMT (inner_then) && !inner_else)
- warning (OPT_Wextra, "%Hempty body in an if-statement",
+ warning (OPT_Wempty_body, "%Hempty body in an if-statement",
EXPR_LOCUS (inner_then));
if (inner_else && IS_EMPTY_STMT (inner_else))
- warning (OPT_Wextra, "%Hempty body in an else-statement",
+ warning (OPT_Wempty_body, "%Hempty body in an else-statement",
EXPR_LOCUS (inner_else));
}
}
diff --git a/gcc/c-opts.c b/gcc/c-opts.c
index dcb68a16fff..9a5d6f6ca3a 100644
--- a/gcc/c-opts.c
+++ b/gcc/c-opts.c
@@ -1025,8 +1025,11 @@ c_common_post_options (const char **pfilename)
if (flag_objc_exceptions && !flag_objc_sjlj_exceptions)
flag_exceptions = 1;
- /* -Wextra implies -Wsign-compare, -Wmissing-field-initializers and
- -Woverride-init, but not if explicitly overridden. */
+ /* -Wextra implies -Wempty-body, -Wsign-compare,
+ -Wmissing-field-initializers and -Woverride-init,
+ but not if explicitly overridden. */
+ if (warn_empty_body == -1)
+ warn_empty_body = extra_warnings;
if (warn_sign_compare == -1)
warn_sign_compare = extra_warnings;
if (warn_missing_field_initializers == -1)
diff --git a/gcc/c-parser.c b/gcc/c-parser.c
index d53b15526c1..b688b15673f 100644
--- a/gcc/c-parser.c
+++ b/gcc/c-parser.c
@@ -3832,7 +3832,7 @@ c_parser_c99_block_statement (c_parser *parser)
is just parsing a statement but (a) it is a block in C99, (b) we
track whether the body is an if statement for the sake of
-Wparentheses warnings, (c) we handle an empty body specially for
- the sake of -Wextra warnings. */
+ the sake of -Wempty-body warnings. */
static tree
c_parser_if_body (c_parser *parser, bool *if_p)
@@ -3844,7 +3844,7 @@ c_parser_if_body (c_parser *parser, bool *if_p)
&& c_parser_peek_2nd_token (parser)->type == CPP_COLON))
c_parser_label (parser);
*if_p = c_parser_next_token_is_keyword (parser, RID_IF);
- if (extra_warnings && c_parser_next_token_is (parser, CPP_SEMICOLON))
+ if (warn_empty_body && c_parser_next_token_is (parser, CPP_SEMICOLON))
add_stmt (build_empty_stmt ());
c_parser_statement_after_labels (parser);
return c_end_compound_stmt (block, flag_isoc99);
diff --git a/gcc/c.opt b/gcc/c.opt
index 8582b20d528..ab04dc2acac 100644
--- a/gcc/c.opt
+++ b/gcc/c.opt
@@ -173,6 +173,10 @@ Weffc++
C++ ObjC++ Var(warn_ecpp)
Warn about violations of Effective C++ style rules
+Wempty-body
+C ObjC C++ ObjC++ Var(warn_empty_body) Init(-1)
+Warn about an empty body in an if or else statement
+
Wendif-labels
C ObjC C++ ObjC++
Warn about stray tokens after #elif and #endif
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index a4aae7ea155..52b1daa1801 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -224,7 +224,8 @@ Objective-C and Objective-C++ Dialects}.
-w -Wextra -Wall -Waggregate-return -Walways-true -Wno-attributes @gol
-Wc++-compat -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol
-Wconversion -Wno-deprecated-declarations @gol
--Wdisabled-optimization -Wno-div-by-zero -Wno-endif-labels @gol
+-Wdisabled-optimization -Wno-div-by-zero @gol
+-Wempty-body -Wno-endif-labels @gol
-Werror -Werror-* -Werror-implicit-function-declaration @gol
-Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
-Wno-format-extra-args -Wformat-nonliteral @gol
@@ -2915,7 +2916,8 @@ void foo(bar) @{ @}
@end smallexample
@item
-An empty body occurs in an @samp{if} or @samp{else} statement.
+An empty body occurs in an @samp{if} or @samp{else} statement. This
+warning can be independently controlled by @option{-Wempty-body}.
@item
A pointer is compared against integer zero with @samp{<}, @samp{<=},
@@ -3165,6 +3167,11 @@ like @code{unsigned ui = -1}; and conversions to smaller types, like
((int) x)} and @code{ui = (unsigned) -1}, or if the value is not
changed by the conversion like in @code{abs (2.0)}.
+@item -Wempty-body
+@opindex Wempty-body
+An empty body occurs in an @samp{if} or @samp{else} statement.
+This warning is also enabled by @option{-Wextra}.
+
@item -Wsign-compare
@opindex Wsign-compare
@cindex warning for comparison of signed and unsigned values
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 486bf17bd92..6d8074e2fc8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2006-12-16 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
+
+ PR middle-end/7651
+ * gcc.dg/20001116-1.c: Replace -Wextra with -Wempty-body.
+ * gcc.dg/if-empty-1.c: Likewise.
+ * gcc.dg/pr23165.c: Likewise.
+ * g++.dg/warn/empty-body.C: Likewise.
+
2006-12-15 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/30005
diff --git a/gcc/testsuite/g++.dg/warn/empty-body.C b/gcc/testsuite/g++.dg/warn/empty-body.C
index 6ca8900fda0..064a09dde2e 100644
--- a/gcc/testsuite/g++.dg/warn/empty-body.C
+++ b/gcc/testsuite/g++.dg/warn/empty-body.C
@@ -1,5 +1,5 @@
// PR c++/5520
-// { dg-options "-O2 -Wextra" }
+// { dg-options "-O2 -Wempty-body" }
void breakme()
{
diff --git a/gcc/testsuite/gcc.dg/20001116-1.c b/gcc/testsuite/gcc.dg/20001116-1.c
index 155cfe63962..3ea2f381d07 100644
--- a/gcc/testsuite/gcc.dg/20001116-1.c
+++ b/gcc/testsuite/gcc.dg/20001116-1.c
@@ -2,7 +2,7 @@
nasty ICE due to messed up parser context. Problem originally found
during bootstrap; this is synthetic. -zw */
/* { dg-do compile }
- { dg-options -W } */
+ { dg-options -Wempty-body } */
void foo (int x)
{
diff --git a/gcc/testsuite/gcc.dg/if-empty-1.c b/gcc/testsuite/gcc.dg/if-empty-1.c
index a3156c1a7f8..9785c72a181 100644
--- a/gcc/testsuite/gcc.dg/if-empty-1.c
+++ b/gcc/testsuite/gcc.dg/if-empty-1.c
@@ -1,7 +1,7 @@
/* Test diagnostics for empty bodies in if / else. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
-/* { dg-options "-Wextra" } */
+/* { dg-options "-Wempty-body" } */
void
f (int x)
diff --git a/gcc/testsuite/gcc.dg/pr23165.c b/gcc/testsuite/gcc.dg/pr23165.c
index 2c63eb16090..94e7daebc90 100644
--- a/gcc/testsuite/gcc.dg/pr23165.c
+++ b/gcc/testsuite/gcc.dg/pr23165.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-Wextra" } */
+/* { dg-options "-Wempty-body" } */
void foo (void)
{
if (0)
OpenPOWER on IntegriCloud