From: manu Date: Fri, 11 May 2012 12:23:50 +0000 (+0000) Subject: 2012-05-11 Manuel López-Ibáñez X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fbb6fbd8cdbfa154ef6da31768c93d48a03a146b;p=thirdparty%2Fgcc.git 2012-05-11 Manuel López-Ibáñez PR 53063 gcc/ * doc/options.texi (EnabledBy): Document * opts.c: Include opts.h and options.h before tm.h. (finish_options): Do not handle some sub-options here... (common_handle_option): ... instead call common_handle_option_auto here. * optc-gen.awk: Handle EnabledBy. * opth-gen.awk: Declare common_handle_option_auto. * common.opt (Wuninitialized): Use EnabledBy. Delete Init. (Wmaybe-uninitialized): Likewise. (Wunused-but-set-variable): Likewise. (Wunused-function): Likewise. (Wunused-label): Likewise. (Wunused-value): Likewise. (Wunused-variable): Likewise. * opt-read.awk: Create opt_numbers array. ada/ * gcc-interface/misc.c (gnat_parse_file): Move before ... (gnat_handle_option): ... this. Use handle_generated_option. c-family/ * c-opts.c (c_common_handle_option): Use handle_generated_option to enable sub-options. fortran/ * options.c: Include diagnostics.h instead of diagnostics-core.h. (set_Wall): Do not see warn_unused here. (gfc_handle_option): Set it here using handle_generated_option. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187403 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c5d733aa88cb..c9f7f499b74f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,21 @@ +2012-05-11 Manuel López-Ibáñez + + PR 53063 + * doc/options.texi (EnabledBy): Document + * opts.c: Include opts.h and options.h before tm.h. + (finish_options): Do not handle some sub-options here... + (common_handle_option): ... instead call common_handle_option_auto here. + * optc-gen.awk: Handle EnabledBy. + * opth-gen.awk: Declare common_handle_option_auto. + * common.opt (Wuninitialized): Use EnabledBy. Delete Init. + (Wmaybe-uninitialized): Likewise. + (Wunused-but-set-variable): Likewise. + (Wunused-function): Likewise. + (Wunused-label): Likewise. + (Wunused-value): Likewise. + (Wunused-variable): Likewise. + * opt-read.awk: Create opt_numbers array. + 2012-05-11 Richard Guenther PR tree-optimization/53295 diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index d24810fed892..537b39e98caa 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2012-05-11 Manuel López-Ibáñez + + PR 53063 + * gcc-interface/misc.c (gnat_parse_file): Move before ... + (gnat_handle_option): ... this. Use handle_generated_option. + 2012-05-10 Richard Guenther * gcc-interface/cuintp.c (UI_From_gnu): Remove TYPE_IS_SIZETYPE use. diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c index 974827a787fc..ad15f6724239 100644 --- a/gcc/ada/gcc-interface/misc.c +++ b/gcc/ada/gcc-interface/misc.c @@ -105,6 +105,14 @@ gnat_parse_file (void) _ada_gnat1drv (); } +/* Return language mask for option processing. */ + +static unsigned int +gnat_option_lang_mask (void) +{ + return CL_Ada; +} + /* Decode all the language specific options that cannot be decoded by GCC. The option decoding phase of GCC calls this routine on the flags that are marked as Ada-specific. Return true on success or false on failure. */ @@ -119,7 +127,10 @@ gnat_handle_option (size_t scode, const char *arg ATTRIBUTE_UNUSED, int value, switch (code) { case OPT_Wall: - warn_unused = value; + handle_generated_option (&global_options, &global_options_set, + OPT_Wunused, NULL, value, + gnat_option_lang_mask (), kind, loc, + handlers, global_dc); warn_uninitialized = value; warn_maybe_uninitialized = value; break; @@ -145,14 +156,6 @@ gnat_handle_option (size_t scode, const char *arg ATTRIBUTE_UNUSED, int value, return true; } -/* Return language mask for option processing. */ - -static unsigned int -gnat_option_lang_mask (void) -{ - return CL_Ada; -} - /* Initialize options structure OPTS. */ static void diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index a01f3eaef459..2c85d515f079 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2012-05-11 Manuel López-Ibáñez + + PR 53063 + * c-opts.c (c_common_handle_option): Use handle_generated_option + to enable sub-options. + 2012-05-10 Paolo Carlini PR c++/53158 diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 2510747c40e5..7d8ee6b334f5 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -360,7 +360,10 @@ c_common_handle_option (size_t scode, const char *arg, int value, break; case OPT_Wall: - warn_unused = value; + handle_generated_option (&global_options, &global_options_set, + OPT_Wunused, NULL, value, + c_family_lang_mask, kind, loc, + handlers, global_dc); set_Wformat (value); handle_generated_option (&global_options, &global_options_set, OPT_Wimplicit, NULL, value, diff --git a/gcc/common.opt b/gcc/common.opt index c25713b31a18..375c10d713e9 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -650,11 +650,11 @@ Common Var(warn_type_limits) Init(-1) Warning Warn if a comparison is always true or always false due to the limited range of the data type Wuninitialized -Common Var(warn_uninitialized) Init(-1) Warning +Common Var(warn_uninitialized) Warning EnabledBy(Wextra) Warn about uninitialized automatic variables Wmaybe-uninitialized -Common Var(warn_maybe_uninitialized) Warning +Common Var(warn_maybe_uninitialized) Warning EnabledBy(Wuninitialized) Warn about maybe uninitialized automatic variables Wunreachable-code @@ -670,15 +670,15 @@ Common Var(warn_unused_but_set_parameter) Init(-1) Warning Warn when a function parameter is only set, otherwise unused Wunused-but-set-variable -Common Var(warn_unused_but_set_variable) Init(-1) Warning +Common Var(warn_unused_but_set_variable) Warning EnabledBy(Wunused) Warn when a variable is only set, otherwise unused Wunused-function -Common Var(warn_unused_function) Init(-1) Warning +Common Var(warn_unused_function) Warning EnabledBy(Wunused) Warn when a function is unused Wunused-label -Common Var(warn_unused_label) Init(-1) Warning +Common Var(warn_unused_label) Warning EnabledBy(Wunused) Warn when a label is unused Wunused-parameter @@ -686,11 +686,11 @@ Common Var(warn_unused_parameter) Init(-1) Warning Warn when a function parameter is unused Wunused-value -Common Var(warn_unused_value) Init(-1) Warning +Common Var(warn_unused_value) Warning EnabledBy(Wunused) Warn when an expression value is unused Wunused-variable -Common Var(warn_unused_variable) Init(-1) Warning +Common Var(warn_unused_variable) Warning EnabledBy(Wunused) Warn when a variable is unused Wcoverage-mismatch diff --git a/gcc/doc/options.texi b/gcc/doc/options.texi index 08b8b793a046..360cbdfb662f 100644 --- a/gcc/doc/options.texi +++ b/gcc/doc/options.texi @@ -459,4 +459,6 @@ combined option. For example, some front ends use this to prevent value of @option{-fmath-errno} for languages that do not use @code{errno}. +@item EnabledBy(@var{opt}) +If not explicitly set, the option is set to the value of @option{-@var{opt}}. @end table diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b26b5c727353..a488dcac5672 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2012-05-11 Manuel López-Ibáñez + + PR 53063 + * options.c: Include diagnostics.h instead of + diagnostics-core.h. + (set_Wall): Do not see warn_unused here. + (gfc_handle_option): Set it here using handle_generated_option. + 2012-05-08 Jan Hubicka * trans-common.c (create_common): Do not fake TREE_ASM_WRITTEN. diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c index dde7ff2f3828..32a8a4cb464c 100644 --- a/gcc/fortran/options.c +++ b/gcc/fortran/options.c @@ -34,7 +34,7 @@ along with GCC; see the file COPYING3. If not see #include "gfortran.h" #include "target.h" #include "cpp.h" -#include "diagnostic-core.h" /* For sorry. */ +#include "diagnostic.h" /* For global_dc. */ #include "tm.h" gfc_option_t gfc_option; @@ -474,7 +474,6 @@ set_Wall (int setting) gfc_option.warn_real_q_constant = setting; gfc_option.warn_unused_dummy_argument = setting; - warn_unused = setting; warn_return_type = setting; warn_switch = setting; warn_uninitialized = setting; @@ -612,6 +611,10 @@ gfc_handle_option (size_t scode, const char *arg, int value, break; case OPT_Wall: + handle_generated_option (&global_options, &global_options_set, + OPT_Wunused, NULL, value, + gfc_option_lang_mask (), kind, loc, + handlers, global_dc); set_Wall (value); break; diff --git a/gcc/opt-read.awk b/gcc/opt-read.awk index 6a4d4de0eb42..81c3ea894d97 100644 --- a/gcc/opt-read.awk +++ b/gcc/opt-read.awk @@ -1,4 +1,4 @@ -# Copyright (C) 2003,2004,2005,2006,2007,2008, 2010, 2011 +# Copyright (C) 2003,2004,2005,2006,2007,2008, 2010, 2011, 2012 # Free Software Foundation, Inc. # Contributed by Kelley Cook, June 2004. # Original code from Neil Booth, May 2003. @@ -108,6 +108,7 @@ BEGIN { name = opt_args("Mask", $1) if (name == "") { opts[n_opts] = $1 + opt_numbers[$1] = n_opts flags[n_opts] = $2 help[n_opts] = $3 for (i = 4; i <= NF; i++) diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk index e28c397f48a9..4dc97f9ca6a5 100644 --- a/gcc/optc-gen.awk +++ b/gcc/optc-gen.awk @@ -1,4 +1,4 @@ -# Copyright (C) 2003, 2004, 2007, 2008, 2009, 2010, 2011 +# Copyright (C) 2003, 2004, 2007, 2008, 2009, 2010, 2011, 2012 # Free Software Foundation, Inc. # Contributed by Kelley Cook, June 2004. # Original code from Neil Booth, May 2003. @@ -324,4 +324,66 @@ for (i = 0; i < n_opts; i++) { print "};" +print "\n\n" +print "bool " +print "common_handle_option_auto (struct gcc_options *opts, " +print " struct gcc_options *opts_set, " +print " const struct cl_decoded_option *decoded, " +print " unsigned int lang_mask, int kind, " +print " location_t loc, " +print " const struct cl_option_handlers *handlers, " +print " diagnostic_context *dc) " +print "{ " +print " size_t scode = decoded->opt_index; " +print " int value = decoded->value; " +print " enum opt_code code = (enum opt_code) scode; " +print " " +print " gcc_assert (decoded->canonical_option_num_elements <= 2); " +print " " +print " switch (code) " +print " { " +n_enabledby = 0; +for (i = 0; i < n_opts; i++) { + # With identical flags, pick only the last one. The + # earlier loop ensured that it has all flags merged, + # and a nonempty help text if one of the texts was nonempty. + while( i + 1 != n_opts && opts[i] == opts[i + 1] ) { + i++; + } + enabledby_arg = opt_args("EnabledBy", flags[i]); + if (enabledby_arg != "") { + enabledby_name = enabledby_arg; + enabledby_index = opt_numbers[enabledby_name]; + if (enabledby_index == "") { + print "#error Enabledby: " enabledby_name + } else { + enabledby_var_name = var_name(flags[enabledby_index]); + if (enables[enabledby_name] == "") { + enabledby[n_enabledby] = enabledby_name; + n_enabledby++; + } + enables[enabledby_name] = enables[enabledby_name] opts[i] ","; + } + } +} +for (i = 0; i < n_enabledby; i++) { + enabledby_name = enabledby[i]; + print " case " opt_enum(enabledby_name) ":" + n_enables = split(enables[enabledby_name], thisenable, ","); + for (j = 1; j < n_enables; j++) { + opt_var_name = var_name(flags[opt_numbers[thisenable[j]]]); + print " if (!opts_set->x_" opt_var_name ")" + print " handle_generated_option (opts, opts_set," + print " " opt_enum(thisenable[j]) ", NULL, value," + print " lang_mask, kind, loc, handlers, dc);" + } + print " break;\n" + +} +print " default: " +print " break; " +print " } " +print " return true; " +print "} " + } diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk index a600b30502b4..8257587e1b34 100644 --- a/gcc/opth-gen.awk +++ b/gcc/opth-gen.awk @@ -1,4 +1,4 @@ -# Copyright (C) 2003,2004,2005,2006,2007,2008, 2010, 2011 +# Copyright (C) 2003,2004,2005,2006,2007,2008, 2010, 2011, 2012 # Free Software Foundation, Inc. # Contributed by Kelley Cook, June 2004. # Original code from Neil Booth, May 2003. @@ -293,6 +293,19 @@ print "extern void cl_target_option_restore (struct gcc_options *, struct cl_tar print ""; print "/* Print target option variables from a structure. */"; print "extern void cl_target_option_print (FILE *, int, struct cl_target_option *);"; +print ""; +print "/* Anything that includes tm.h, does not necessarily need this. */" +print "#if !defined(GCC_TM_H)" +print "#include \"input.h\" /* for location_t */" +print "bool " +print "common_handle_option_auto (struct gcc_options *opts, " +print " struct gcc_options *opts_set, " +print " const struct cl_decoded_option *decoded, " +print " unsigned int lang_mask, int kind, " +print " location_t loc, " +print " const struct cl_option_handlers *handlers, " +print " diagnostic_context *dc); " +print "#endif"; print "#endif"; print ""; diff --git a/gcc/opts.c b/gcc/opts.c index b6c786f950e2..ac43d4a2da7c 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -1,5 +1,7 @@ /* Command line option handling. - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 + Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, + 2012 + Free Software Foundation, Inc. Contributed by Neil Booth. @@ -23,11 +25,11 @@ along with GCC; see the file COPYING3. If not see #include "system.h" #include "intl.h" #include "coretypes.h" +#include "opts.h" +#include "options.h" #include "tm.h" /* For STACK_CHECK_BUILTIN, STACK_CHECK_STATIC_BUILTIN, DEFAULT_GDB_EXTENSIONS, DWARF2_DEBUGGING_INFO and DBX_DEBUGGING_INFO. */ -#include "opts.h" -#include "options.h" #include "flags.h" #include "params.h" #include "diagnostic.h" @@ -815,33 +817,18 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set, opts->x_param_values, opts_set->x_param_values); /* This replaces set_Wunused. */ - if (opts->x_warn_unused_function == -1) - opts->x_warn_unused_function = opts->x_warn_unused; - if (opts->x_warn_unused_label == -1) - opts->x_warn_unused_label = opts->x_warn_unused; /* Wunused-parameter is enabled if both -Wunused -Wextra are enabled. */ if (opts->x_warn_unused_parameter == -1) opts->x_warn_unused_parameter = (opts->x_warn_unused && opts->x_extra_warnings); - if (opts->x_warn_unused_variable == -1) - opts->x_warn_unused_variable = opts->x_warn_unused; /* Wunused-but-set-parameter is enabled if both -Wunused -Wextra are enabled. */ if (opts->x_warn_unused_but_set_parameter == -1) opts->x_warn_unused_but_set_parameter = (opts->x_warn_unused && opts->x_extra_warnings); - if (opts->x_warn_unused_but_set_variable == -1) - opts->x_warn_unused_but_set_variable = opts->x_warn_unused; - if (opts->x_warn_unused_value == -1) - opts->x_warn_unused_value = opts->x_warn_unused; - /* Wunused-local-typedefs is enabled by -Wunused or -Wall. */ if (opts->x_warn_unused_local_typedefs == -1) opts->x_warn_unused_local_typedefs = opts->x_warn_unused; - - /* This replaces set_Wextra. */ - if (opts->x_warn_uninitialized == -1) - opts->x_warn_uninitialized = opts->x_extra_warnings; } #define LEFT_COLUMN 27 @@ -1745,11 +1732,6 @@ common_handle_option (struct gcc_options *opts, /* No-op. Used by the driver and passed to us because it starts with f.*/ break; - case OPT_Wuninitialized: - /* Also turn on maybe uninitialized warning. */ - opts->x_warn_maybe_uninitialized = value; - break; - default: /* If the flag was handled in a standard way, assume the lack of processing here is intentional. */ @@ -1757,6 +1739,8 @@ common_handle_option (struct gcc_options *opts, break; } + common_handle_option_auto (opts, opts_set, decoded, lang_mask, kind, + loc, handlers, dc); return true; }