From: Manuel López-Ibáñez Date: Fri, 8 Aug 2008 23:15:31 +0000 (+0000) Subject: re PR c/28875 ("-Wextra -Wno-unused-parameter -Wall" doesn't work as expected) X-Git-Tag: releases/gcc-4.4.0~3227 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e73f7547c50e91654c691a620a949085645c4e51;p=thirdparty%2Fgcc.git re PR c/28875 ("-Wextra -Wno-unused-parameter -Wall" doesn't work as expected) 2008-08-08 Manuel Lopez-Ibanez PR 28875 * flags.h (set_Wunused): Delete * toplev.c (process_options): Handle Wunused flags here. * opts.c (maybe_warn_unused_parameter): Delete. (common_handle_option): Replace set_Wunused by warn_unused. (set_Wextra): Do not handle Wunused-parameter here. (set_Wunused): Delete. * c-opts.c (c_common_handle_option): Replace set_Wunused by warn_unused. * common.opt (Wunused): Add Var and Init. (Wunused-function): Likewise. (Wunused-label): Likewise. (Wunused-parameter): Likewise. (Wunused-value): Likewise. (Wunused-variable): Likewise. fortran/ * options.c (set_Wall): Replace set_Wunused by warn_unused. java/ * lang.c (java_handle_option): Replace set_Wunused with warn_unused. testsuite/ * gcc.dg/unused-6-no.c: New. * gcc.dg/unused-6-WallWextra.c: New. From-SVN: r138890 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ed2707a7923e..569efd1f5b32 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,17 +1,35 @@ +2008-08-08 Manuel Lopez-Ibanez + + PR 28875 + * flags.h (set_Wunused): Delete + * toplev.c (process_options): Handle Wunused flags here. + * opts.c (maybe_warn_unused_parameter): Delete. + (common_handle_option): Replace set_Wunused by warn_unused. + (set_Wextra): Do not handle Wunused-parameter here. + (set_Wunused): Delete. + * c-opts.c (c_common_handle_option): Replace set_Wunused by + warn_unused. + * common.opt (Wunused): Add Var and Init. + (Wunused-function): Likewise. + (Wunused-label): Likewise. + (Wunused-parameter): Likewise. + (Wunused-value): Likewise. + (Wunused-variable): Likewise. + 2008-08-08 Peter Bergner - * doc/invoke.texi: Add cpu_type power7. - * config.in (HAVE_AS_VSX): New. - * config.gcc: Add cpu_type power7. - * configure.ac (HAVE_AS_VSX): Check for assembler support of the - VSX instructions. - * configure: Regenerate. - * config/rs6000/rs6000.c (rs6000_override_options): Alias power7 to - power5. - * config/rs6000/rs6000.h (ASM_CPU_POWER7_SPEC): Define. - (ASM_CPU_SPEC): Pass %(asm_cpu_power7) for -mcpu=power7. - (EXTRA_SPECS): Add asm_cpu_power7 spec string. - + * doc/invoke.texi: Add cpu_type power7. + * config.in (HAVE_AS_VSX): New. + * config.gcc: Add cpu_type power7. + * configure.ac (HAVE_AS_VSX): Check for assembler support of the + VSX instructions. + * configure: Regenerate. + * config/rs6000/rs6000.c (rs6000_override_options): Alias power7 to + power5. + * config/rs6000/rs6000.h (ASM_CPU_POWER7_SPEC): Define. + (ASM_CPU_SPEC): Pass %(asm_cpu_power7) for -mcpu=power7. + (EXTRA_SPECS): Add asm_cpu_power7 spec string. + 2008-08-08 Dorit Nuzman * tree-vect-transform.c (vectorizable_conversion): Pass the integral diff --git a/gcc/c-opts.c b/gcc/c-opts.c index 8b31b8879e7c..83e2ed14c4ea 100644 --- a/gcc/c-opts.c +++ b/gcc/c-opts.c @@ -376,7 +376,7 @@ c_common_handle_option (size_t scode, const char *arg, int value) break; case OPT_Wall: - set_Wunused (value); + warn_unused = value; set_Wformat (value); set_Wimplicit (value); warn_char_subscripts = value; diff --git a/gcc/common.opt b/gcc/common.opt index 02bdef255886..9b1972b8c4a6 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -210,27 +210,27 @@ Common Var(warn_notreached) Warning Warn about code that will never be executed Wunused -Common Warning +Common Var(warn_unused) Init(0) Warning Enable all -Wunused- warnings Wunused-function -Common Var(warn_unused_function) Warning +Common Var(warn_unused_function) Init(-1) Warning Warn when a function is unused Wunused-label -Common Var(warn_unused_label) Warning +Common Var(warn_unused_label) Init(-1) Warning Warn when a label is unused Wunused-parameter -Common Var(warn_unused_parameter) Warning +Common Var(warn_unused_parameter) Init(-1) Warning Warn when a function parameter is unused Wunused-value -Common Var(warn_unused_value) Warning +Common Var(warn_unused_value) Init(-1) Warning Warn when an expression value is unused Wunused-variable -Common Var(warn_unused_variable) Warning +Common Var(warn_unused_variable) Init(-1) Warning Warn when a variable is unused Wcoverage-mismatch diff --git a/gcc/flags.h b/gcc/flags.h index e797d95c885c..ceff962d98a4 100644 --- a/gcc/flags.h +++ b/gcc/flags.h @@ -115,12 +115,6 @@ extern int optimize_size; extern bool extra_warnings; -/* Nonzero to warn about unused variables, functions et.al. Use - set_Wunused() to update the -Wunused-* flags that correspond to the - -Wunused option. */ - -extern void set_Wunused (int setting); - /* Used to set the level of -Wstrict-aliasing, when no level is specified. The external way to set the default level is to use -Wstrict-aliasing=level. diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9b51d994826e..6e37b804d8e5 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2008-08-08 Manuel Lopez-Ibanez + + PR 28875 + * options.c (set_Wall): Replace set_Wunused by warn_unused. + 2008-08-08 Daniel Kraft * gfortran.h (gfc_finalizer): Replaced member `procedure' by two diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c index 7b7916d46036..4ecb8f998e33 100644 --- a/gcc/fortran/options.c +++ b/gcc/fortran/options.c @@ -376,7 +376,7 @@ set_Wall (int setting) gfc_option.warn_intrinsics_std = setting; gfc_option.warn_character_truncation = setting; - set_Wunused (setting); + warn_unused = setting; warn_return_type = setting; warn_switch = setting; diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index b2321e374f80..ba39be429716 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,9 @@ +2008-08-08 Manuel Lopez-Ibanez + + PR 28875 + * lang.c (java_handle_option): Replace set_Wunused with + warn_unused. + 2008-07-30 Ralf Wildenhues * gcj.texi: Update copyright years. Do not list GPL as diff --git a/gcc/java/lang.c b/gcc/java/lang.c index 27383762add0..d049aeb2bc16 100644 --- a/gcc/java/lang.c +++ b/gcc/java/lang.c @@ -221,7 +221,7 @@ java_handle_option (size_t scode, const char *arg, int value) flag_wall = value; /* When -Wall given, enable -Wunused. We do this because the C compiler does it, and people expect it. */ - set_Wunused (value); + warn_unused = value; break; case OPT_fenable_assertions_: diff --git a/gcc/opts.c b/gcc/opts.c index 54512513f425..8dd8b8265fdf 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -63,9 +63,6 @@ HOST_WIDE_INT larger_than_size; bool warn_frame_larger_than; HOST_WIDE_INT frame_larger_than_size; -/* Hack for cooperation between set_Wunused and set_Wextra. */ -static bool maybe_warn_unused_parameter; - /* Type(s) of debugging information we are producing (if any). See flags.h for the definitions of the different possible types of debugging information. */ @@ -1667,7 +1664,7 @@ common_handle_option (size_t scode, const char *arg, int value, break; case OPT_Wunused: - set_Wunused (value); + warn_unused = value; break; case OPT_aux_info: @@ -2037,7 +2034,6 @@ static void set_Wextra (int setting) { extra_warnings = 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 @@ -2048,23 +2044,6 @@ set_Wextra (int setting) warn_uninitialized = 2; } -/* Initialize unused warning flags. */ -void -set_Wunused (int setting) -{ - warn_unused_function = setting; - warn_unused_label = setting; - /* 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; -} - /* Used to set the level of strict aliasing warnings, when no level is specified (i.e., when -Wstrict-aliasing, and not -Wstrict-aliasing=level was given). diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 22bd5e5e4d4e..db2088fac1a1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-08-08 Manuel Lopez-Ibanez + + PR 28875 + * gcc.dg/unused-6-no.c: New. + * gcc.dg/unused-6-WallWextra.c: New. + 2008-08-08 Volker Reichelt PR c++/35985 diff --git a/gcc/testsuite/gcc.dg/unused-6-WallWextra.c b/gcc/testsuite/gcc.dg/unused-6-WallWextra.c new file mode 100644 index 000000000000..d2d80be062a0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/unused-6-WallWextra.c @@ -0,0 +1,11 @@ +/* PR 28875 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -Wextra -Wall" } */ +static int t(int i) /* { dg-warning "unused parameter" "unused parameter warning" } */ +{ + return 0; +} +int tt() +{ + return t(0); +} diff --git a/gcc/testsuite/gcc.dg/unused-6-no.c b/gcc/testsuite/gcc.dg/unused-6-no.c new file mode 100644 index 000000000000..0923cfb8132d --- /dev/null +++ b/gcc/testsuite/gcc.dg/unused-6-no.c @@ -0,0 +1,11 @@ +/* PR 28875 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -Wextra -Wno-unused-parameter -Wall" } */ +static int t(int i) /* { dg-bogus "unused parameter" "unused parameter warning" } */ +{ + return 0; +} +int tt() +{ + return t(0); +} diff --git a/gcc/toplev.c b/gcc/toplev.c index d717ebace2a8..bb49a970b49b 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1644,6 +1644,19 @@ process_options (void) This can happen with incorrect pre-processed input. */ debug_hooks = &do_nothing_debug_hooks; + /* This replaces set_Wunused. */ + if (warn_unused_function == -1) + warn_unused_function = warn_unused; + if (warn_unused_label == -1) + warn_unused_label = warn_unused; + /* Wunused-parameter is enabled if both -Wunused -Wextra are enabled. */ + if (warn_unused_parameter == -1) + warn_unused_parameter = (warn_unused && extra_warnings); + if (warn_unused_variable == -1) + warn_unused_variable = warn_unused; + if (warn_unused_value == -1) + warn_unused_value = warn_unused; + /* Allow the front end to perform consistency checks and do further initialization based on the command line options. This hook also sets the original filename if appropriate (e.g. foo.i -> foo.c)