diff options
author | Zack Weinberg <zack@gcc.gnu.org> | 2003-05-03 21:44:31 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2003-05-03 21:44:31 +0000 |
commit | 87f85ea0660e58ac0f2447d1c4a593863601df0e (patch) | |
tree | e37cc59b695cc55218915e90bcce25c7621fdf58 /gcc/toplev.c | |
parent | e7b5f0c9b4aa73a1de50162ae18101dab4f86ce4 (diff) | |
download | gcc-87f85ea0660e58ac0f2447d1c4a593863601df0e.zip gcc-87f85ea0660e58ac0f2447d1c4a593863601df0e.tar.gz gcc-87f85ea0660e58ac0f2447d1c4a593863601df0e.tar.bz2 |
re PR c/10604 (-Wall includes sign conversion warning [3.3 regression])
PR c/10604
* c-common.c (warn_sign_compare): Initialize to -1.
* c-opts.c (c_common_init_options): Don't set warn_sign_compare here.
(c_common_decode_option <OPT_Wall>): Set warn_sign_compare
for C++ only.
(c_common_post_options): Set warn_sign_compare from extra_warnings
if it's still -1 at this point.
* toplev.c (maybe_warn_unused_parameter): New static variable.
(set_Wextra): New static function.
(W_options): Remove "extra".
(decode_W_option): Call set_Wextra.
(independent_decode_option): Likewise.
(set_Wunused): Cooperate with set_Wextra in setting
warn_unused_parameter.
(rest_of_compilation): No need to check extra_warnings as
well as warn_uninitialized.
* c-typeck.c (build_binary_op, build_conditional_expr):
No need to check extra_warnings as well as warn_sign_compare.
(internal_build_compound_expr): No need to check extra_warnings
as well as warn_unused_value.
* function.c (expand_function_end): No need to check extra_warnings
as well as warn_unused_parameter.
* stmt.c (expand_expr_stmt_value): No need to check extra_warnings
as well as warn_unused_value.
* cp/typeck.c (build_x_compound_expr): No need to check
extra_warnings as well as warn_unused_value.
* doc/invoke.texi: Clarify documentation of -Wsign-compare.
* gcc.dg/compare7.c, g++.dg/warn/compare1.C: New testcases.
* Makefile.in: Disable -Werror for gengtype-lex.o.
From-SVN: r66436
Diffstat (limited to 'gcc/toplev.c')
-rw-r--r-- | gcc/toplev.c | 60 |
1 files changed, 37 insertions, 23 deletions
diff --git a/gcc/toplev.c b/gcc/toplev.c index 065952b..30bae57 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -124,6 +124,7 @@ static int decode_f_option PARAMS ((const char *)); static int decode_W_option PARAMS ((const char *)); static int decode_g_option PARAMS ((const char *)); static unsigned int independent_decode_option PARAMS ((int, char **)); +static void set_Wextra PARAMS ((int)); static void print_version PARAMS ((FILE *, const char *)); static int print_single_switch PARAMS ((FILE *, int, int, const char *, @@ -1463,6 +1464,9 @@ int warn_unused_parameter; int warn_unused_variable; int warn_unused_value; +/* Used for cooperation between set_Wunused and set_Wextra. */ +static int maybe_warn_unused_parameter; + /* Nonzero to warn about code which is never reached. */ int warn_notreached; @@ -1586,8 +1590,6 @@ static const lang_independent_options W_options[] = N_("Warn when an optimization pass is disabled") }, {"deprecated-declarations", &warn_deprecated_decl, 1, N_("Warn about uses of __attribute__((deprecated)) declarations") }, - {"extra", &extra_warnings, 1, - N_("Print extra (possibly unwanted) warnings") }, {"missing-noreturn", &warn_missing_noreturn, 1, N_("Warn about functions which might be candidates for attribute noreturn") }, {"strict-aliasing", &warn_strict_aliasing, 1, @@ -1600,17 +1602,34 @@ set_Wunused (setting) { warn_unused_function = setting; warn_unused_label = setting; - /* Unused function parameter warnings are reported when either ``-W - -Wunused'' or ``-Wunused-parameter'' is specified. Differentiate - -Wunused by setting WARN_UNUSED_PARAMETER to -1. */ - if (!setting) - warn_unused_parameter = 0; - else if (!warn_unused_parameter) - warn_unused_parameter = -1; + /* Unused function parameter warnings are reported when either + ``-Wextra -Wunused'' or ``-Wunused-parameter'' is specified. + Thus, if -Wextra has already been seen, set warn_unused_parameter; + otherwise set maybe_warn_extra_parameter, which will be picked up + by set_Wextra. */ + maybe_warn_unused_parameter = setting; + warn_unused_parameter = (setting && extra_warnings); warn_unused_variable = setting; warn_unused_value = setting; } +static void +set_Wextra (setting) + int setting; +{ + extra_warnings = setting; + warn_unused_value = setting; + warn_unused_parameter = (setting && maybe_warn_unused_parameter); + + /* We save the value of warn_uninitialized, since if they put + -Wuninitialized on the command line, we need to generate a + warning about not using it without also specifying -O. */ + if (setting == 0) + warn_uninitialized = 0; + else if (warn_uninitialized != 1) + warn_uninitialized = 2; +} + /* The following routines are useful in setting all the flags that -ffast-math and -fno-fast-math imply. */ @@ -3206,7 +3225,7 @@ rest_of_compilation (decl) | (flag_thread_jumps ? CLEANUP_THREADING : 0)); timevar_pop (TV_FLOW); - if (warn_uninitialized || extra_warnings) + if (warn_uninitialized) { uninitialized_vars_warning (DECL_INITIAL (decl)); if (extra_warnings) @@ -3874,6 +3893,7 @@ display_help () W_options[i].string, _(description)); } + printf (_(" -Wextra Print extra (possibly unwanted) warnings\n")); printf (_(" -Wunused Enable unused warnings\n")); printf (_(" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n")); printf (_(" -p Enable function profiling\n")); @@ -4256,11 +4276,11 @@ decode_W_option (arg) } else if (!strcmp (arg, "extra")) { - /* We save the value of warn_uninitialized, since if they put - -Wuninitialized on the command line, we need to generate a - warning about not using it without also specifying -O. */ - if (warn_uninitialized != 1) - warn_uninitialized = 2; + set_Wextra (1); + } + else if (!strcmp (arg, "no-extra")) + { + set_Wextra (0); } else return 0; @@ -4539,15 +4559,9 @@ independent_decode_option (argc, argv) break; case 'W': + /* For backward compatibility, -W is the same as -Wextra. */ if (arg[1] == 0) - { - extra_warnings = 1; - /* We save the value of warn_uninitialized, since if they put - -Wuninitialized on the command line, we need to generate a - warning about not using it without also specifying -O. */ - if (warn_uninitialized != 1) - warn_uninitialized = 2; - } + set_Wextra (1); else return decode_W_option (arg + 1); break; |