re PR c/53063 (encode group options in the .opt files)

2012-05-11  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	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.

From-SVN: r187403
parent 319e6439
2012-05-11 Manuel López-Ibáñez <manu@gcc.gnu.org>
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 <rguenther@suse.de>
PR tree-optimization/53295
......
2012-05-11 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR 53063
* gcc-interface/misc.c (gnat_parse_file): Move before ...
(gnat_handle_option): ... this. Use handle_generated_option.
2012-05-10 Richard Guenther <rguenther@suse.de>
* gcc-interface/cuintp.c (UI_From_gnu): Remove TYPE_IS_SIZETYPE use.
......
......@@ -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
......
2012-05-11 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR 53063
* c-opts.c (c_common_handle_option): Use handle_generated_option
to enable sub-options.
2012-05-10 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/53158
......
......@@ -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,
......
......@@ -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
......
......@@ -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
2012-05-11 Manuel López-Ibáñez <manu@gcc.gnu.org>
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 <jh@suse.cz>
* trans-common.c (create_common): Do not fake TREE_ASM_WRITTEN.
......
......@@ -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;
......
# 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++)
......
# 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 "} "
}
# 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 "";
......
/* 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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment