aboutsummaryrefslogtreecommitdiff
path: root/gcc/opts-common.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2010-10-05 15:28:39 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2010-10-05 15:28:39 +0100
commit1ebe4b4fa0b30f6ef7cb18404def5854745b5912 (patch)
tree43c4d6f7a1bd908c7de82db7e4231d62541f883a /gcc/opts-common.c
parentbcee41ff81d1c5aee58820299fe51eaf4545f3c0 (diff)
downloadgcc-1ebe4b4fa0b30f6ef7cb18404def5854745b5912.zip
gcc-1ebe4b4fa0b30f6ef7cb18404def5854745b5912.tar.gz
gcc-1ebe4b4fa0b30f6ef7cb18404def5854745b5912.tar.bz2
opts-common.c (handle_option, [...]): Add diagnostic_context parameter.
* opts-common.c (handle_option, handle_generated_option, read_cmdline_option, set_option): Add diagnostic_context parameter. Update calls among these functions. (set_option): Don't use global_dc. * opts.c (read_cmdline_options): Pass global_dc to read_cmdline_option. (decode_options): Pass global_dc to enable_warning_as_error. (common_handle_option): Pass global_dc to enable_warning_as_error. (enable_warning_as_error): Add diagnostic_context parameter. Document parameters. Don't use global_dc. Pass diagnostic_context parameter to handle_generated_option. * opts.h (set_option, handle_option, handle_generated_option, read_cmdline_option, enable_warning_as_error): Add diagnostic_context parameter. * Makefile.in (lto-opts.o): Update dependencies. * coretypes.h (struct diagnostic_context, diagnostic_context): Declare here. * diagnostic.h (diagnostic_context): Don't declare typedef here. * gcc.c (process_command): Pass global_dc to read_cmdline_option. * langhooks-def.h (struct diagnostic_context): Don't declare here. (lhd_print_error_function, lhd_initialize_diagnostics): Declare using diagnostic_context typedef. * langhooks.c (lhd_initialize_diagnostics): Declare using diagnostic_context typedef. * langhooks.h (struct diagnostic_context): Don't declare here. (initialize_diagnostics, print_error_function): Declare using diagnostic_context typedef. * lto-opts.c: Include diagnostic.h. (lto_reissue_options): Pass global_dc to set_option. Pass DK_UNSPECIFIED not 0. * plugin.c (plugins_internal_error_function): Declare using diagnostic_context typedef. * plugin.h (struct diagnostic_context): Don't declare here. (plugins_internal_error_function): Declare using diagnostic_context typedef. c-family: * c-common.h (struct diagnostic_context): Don't declare here. (c_common_initialize_diagnostics): Declare using diagnostic_context typedef. * c-opts.c (c_common_handle_option): Pass global_dc to handle_generated_option. cp: * cp-tree.h (cxx_print_error_function, cxx_initialize_diagnostics): Declare using diagnostic_context typedef. From-SVN: r164991
Diffstat (limited to 'gcc/opts-common.c')
-rw-r--r--gcc/opts-common.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index 5ac4fab..a5f66ce 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -804,7 +804,8 @@ keep:
option, DK_UNSPECIFIED otherwise. GENERATED_P is true for an
option generated as part of processing another option or otherwise
generated internally, false for one explicitly passed by the user.
- Returns false if the switch was invalid. */
+ Returns false if the switch was invalid. DC is the diagnostic
+ context for options affecting diagnostics state, or NULL. */
bool
handle_option (struct gcc_options *opts,
@@ -812,7 +813,7 @@ handle_option (struct gcc_options *opts,
const struct cl_decoded_option *decoded,
unsigned int lang_mask, int kind,
const struct cl_option_handlers *handlers,
- bool generated_p)
+ bool generated_p, diagnostic_context *dc)
{
size_t opt_index = decoded->opt_index;
const char *arg = decoded->arg;
@@ -823,7 +824,7 @@ handle_option (struct gcc_options *opts,
if (flag_var)
set_option (opts, (generated_p ? NULL : opts_set),
- opt_index, value, arg, kind);
+ opt_index, value, arg, kind, dc);
for (i = 0; i < handlers->num_handlers; i++)
if (option->flags & handlers->handlers[i].mask)
@@ -849,13 +850,14 @@ handle_generated_option (struct gcc_options *opts,
struct gcc_options *opts_set,
size_t opt_index, const char *arg, int value,
unsigned int lang_mask, int kind,
- const struct cl_option_handlers *handlers)
+ const struct cl_option_handlers *handlers,
+ diagnostic_context *dc)
{
struct cl_decoded_option decoded;
generate_option (opt_index, arg, value, lang_mask, &decoded);
return handle_option (opts, opts_set, &decoded, lang_mask, kind, handlers,
- true);
+ true, dc);
}
/* Fill in *DECODED with an option described by OPT_INDEX, ARG and
@@ -915,14 +917,16 @@ generate_option_input_file (const char *file,
/* Handle the switch DECODED for the language indicated by LANG_MASK,
using the handlers in *HANDLERS and setting fields in OPTS and
- OPTS_SET. */
+ OPTS_SET and using diagnostic context DC (if not NULL) for
+ diagnostic options. */
void
read_cmdline_option (struct gcc_options *opts,
struct gcc_options *opts_set,
struct cl_decoded_option *decoded,
unsigned int lang_mask,
- const struct cl_option_handlers *handlers)
+ const struct cl_option_handlers *handlers,
+ diagnostic_context *dc)
{
const struct cl_option *option;
const char *opt = decoded->orig_option_with_args_text;
@@ -974,16 +978,19 @@ read_cmdline_option (struct gcc_options *opts,
gcc_assert (!decoded->errors);
if (!handle_option (opts, opts_set, decoded, lang_mask, DK_UNSPECIFIED,
- handlers, false))
+ handlers, false, dc))
error ("unrecognized command line option %qs", opt);
}
/* Set any field in OPTS, and OPTS_SET if not NULL, for option
- OPT_INDEX according to VALUE and ARG, diagnostic kind KIND. */
+ OPT_INDEX according to VALUE and ARG, diagnostic kind KIND, using
+ diagnostic context DC if not NULL for diagnostic
+ classification. */
void
set_option (struct gcc_options *opts, struct gcc_options *opts_set,
- int opt_index, int value, const char *arg, int kind)
+ int opt_index, int value, const char *arg, int kind,
+ diagnostic_context *dc)
{
const struct cl_option *option = &cl_options[opt_index];
void *flag_var = option_flag_var (opt_index, opts);
@@ -1028,8 +1035,9 @@ set_option (struct gcc_options *opts, struct gcc_options *opts_set,
break;
}
- if ((diagnostic_t) kind != DK_UNSPECIFIED)
- diagnostic_classify_diagnostic (global_dc, opt_index, (diagnostic_t) kind,
+ if ((diagnostic_t) kind != DK_UNSPECIFIED
+ && dc != NULL)
+ diagnostic_classify_diagnostic (dc, opt_index, (diagnostic_t) kind,
UNKNOWN_LOCATION);
}