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.
From-SVN: r119963
+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
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))
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));
}
}
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)
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)
&& 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);
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
-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
@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{<=},
((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
+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
// PR c++/5520
-// { dg-options "-O2 -Wextra" }
+// { dg-options "-O2 -Wempty-body" }
void breakme()
{
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)
{
/* 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)
/* { dg-do compile } */
-/* { dg-options "-Wextra" } */
+/* { dg-options "-Wempty-body" } */
void foo (void)
{
if (0)