mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-24 16:30:53 +08:00
re PR middle-end/7651 (Define -Wextra strictly in terms of other warning flags)
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
This commit is contained in:
parent
d6b418fa0b
commit
b3b433c507
@ -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
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -1,5 +1,5 @@
|
||||
// PR c++/5520
|
||||
// { dg-options "-O2 -Wextra" }
|
||||
// { dg-options "-O2 -Wempty-body" }
|
||||
|
||||
void breakme()
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-Wextra" } */
|
||||
/* { dg-options "-Wempty-body" } */
|
||||
void foo (void)
|
||||
{
|
||||
if (0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user