struct gcc_options *opts_set,
const struct cl_decoded_option *decoded,
unsigned int lang_mask, int kind,
+ location_t loc,
const struct cl_option_handlers *handlers,
diagnostic_context *dc);
static void handle_param (struct gcc_options *opts,
static void set_fast_math_flags (struct gcc_options *opts, int set);
static void set_unsafe_math_optimizations_flags (struct gcc_options *opts,
int set);
+static void enable_warning_as_error (const char *arg, int value,
+ unsigned int lang_mask,
+ const struct cl_option_handlers *handlers,
+ struct gcc_options *opts,
+ struct gcc_options *opts_set,
+ location_t loc,
+ diagnostic_context *dc);
/* Return a malloced slash-separated list of languages in MASK. */
static char *
struct gcc_options *opts_set,
const struct cl_decoded_option *decoded,
unsigned int lang_mask ATTRIBUTE_UNUSED, int kind,
+ location_t loc,
const struct cl_option_handlers *handlers,
diagnostic_context *dc)
{
gcc_assert (dc == global_dc);
gcc_assert (decoded->canonical_option_num_elements <= 2);
return lang_hooks.handle_option (decoded->opt_index, decoded->arg,
- decoded->value, kind, handlers);
+ decoded->value, kind, loc, handlers);
}
/* Handle a back-end option; arguments and return value as for
struct gcc_options *opts_set,
const struct cl_decoded_option *decoded,
unsigned int lang_mask ATTRIBUTE_UNUSED, int kind,
+ location_t loc,
const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED,
diagnostic_context *dc)
{
gcc_assert (dc == global_dc);
gcc_assert (decoded->canonical_option_num_elements <= 2);
gcc_assert (kind == DK_UNSPECIFIED);
+ gcc_assert (loc == UNKNOWN_LOCATION);
return targetm.handle_option (decoded->opt_index, decoded->arg,
decoded->value);
}
}
-/* Handle the vector of command line options, storing the results of
- processing DECODED_OPTIONS and DECODED_OPTIONS_COUNT in OPTS and
- OPTS_SET and using DC for diagnostic state. LANG_MASK contains has
- a single bit set representing the current language. HANDLERS
- describes what functions to call for the options. */
+/* Handle the vector of command line options (located at LOC), storing
+ the results of processing DECODED_OPTIONS and DECODED_OPTIONS_COUNT
+ in OPTS and OPTS_SET and using DC for diagnostic state. LANG_MASK
+ contains has a single bit set representing the current language.
+ HANDLERS describes what functions to call for the options. */
static void
read_cmdline_options (struct gcc_options *opts, struct gcc_options *opts_set,
struct cl_decoded_option *decoded_options,
unsigned int decoded_options_count,
+ location_t loc,
unsigned int lang_mask,
const struct cl_option_handlers *handlers,
diagnostic_context *dc)
}
read_cmdline_option (opts, opts_set,
- decoded_options + i, lang_mask, handlers,
+ decoded_options + i, loc, lang_mask, handlers,
dc);
}
}
/* If indicated by the optimization level LEVEL (-Os if SIZE is set,
-Ofast if FAST is set), apply the option DEFAULT_OPT to OPTS and
- OPTS_SET, diagnostic context DC, with language mask LANG_MASK and
- option handlers HANDLERS. */
+ OPTS_SET, diagnostic context DC, location LOC, with language mask
+ LANG_MASK and option handlers HANDLERS. */
static void
maybe_default_option (struct gcc_options *opts,
int level, bool size, bool fast,
unsigned int lang_mask,
const struct cl_option_handlers *handlers,
+ location_t loc,
diagnostic_context *dc)
{
const struct cl_option *option = &cl_options[default_opt->opt_index];
if (enabled)
handle_generated_option (opts, opts_set, default_opt->opt_index,
default_opt->arg, default_opt->value,
- lang_mask, DK_UNSPECIFIED, handlers, dc);
+ lang_mask, DK_UNSPECIFIED, loc,
+ handlers, dc);
else if (default_opt->arg == NULL
&& !(option->flags & CL_REJECT_NEGATIVE))
handle_generated_option (opts, opts_set, default_opt->opt_index,
default_opt->arg, !default_opt->value,
- lang_mask, DK_UNSPECIFIED, handlers, dc);
+ lang_mask, DK_UNSPECIFIED, loc,
+ handlers, dc);
}
/* As indicated by the optimization level LEVEL (-Os if SIZE is set,
-Ofast if FAST is set), apply the options in array DEFAULT_OPTS to
- OPTS and OPTS_SET, diagnostic context DC, with language mask
- LANG_MASK and option handlers HANDLERS. */
+ OPTS and OPTS_SET, diagnostic context DC, location LOC, with
+ language mask LANG_MASK and option handlers HANDLERS. */
static void
maybe_default_options (struct gcc_options *opts,
int level, bool size, bool fast,
unsigned int lang_mask,
const struct cl_option_handlers *handlers,
+ location_t loc,
diagnostic_context *dc)
{
size_t i;
for (i = 0; default_opts[i].levels != OPT_LEVELS_NONE; i++)
maybe_default_option (opts, opts_set, &default_opts[i],
- level, size, fast, lang_mask, handlers, dc);
+ level, size, fast, lang_mask, handlers, loc, dc);
}
/* Table of options enabled by default at different levels. */
struct gcc_options *opts_set,
struct cl_decoded_option *decoded_options,
unsigned int decoded_options_count,
+ location_t loc,
unsigned int lang_mask,
const struct cl_option_handlers *handlers,
diagnostic_context *dc)
maybe_default_options (opts, opts_set, default_options_table,
opts->x_optimize, opts->x_optimize_size,
- ofast, lang_mask, handlers, dc);
+ ofast, lang_mask, handlers, loc, dc);
/* -O2 param settings. */
opt2 = (opts->x_optimize >= 2);
maybe_default_options (opts, opts_set,
targetm.target_option.optimization_table,
opts->x_optimize, opts->x_optimize_size,
- ofast, lang_mask, handlers, dc);
+ ofast, lang_mask, handlers, loc, dc);
}
static void finish_options (struct gcc_options *, struct gcc_options *);
+/* Set *HANDLERS to the default set of option handlers for use in the
+ compilers proper (not the driver). */
+void
+set_default_handlers (struct cl_option_handlers *handlers)
+{
+ handlers->unknown_option_callback = unknown_option_callback;
+ handlers->wrong_lang_callback = complain_wrong_lang;
+ handlers->post_handling_callback = post_handling_callback;
+ handlers->num_handlers = 3;
+ handlers->handlers[0].handler = lang_handle_option;
+ handlers->handlers[0].mask = initial_lang_mask;
+ handlers->handlers[1].handler = common_handle_option;
+ handlers->handlers[1].mask = CL_COMMON;
+ handlers->handlers[2].handler = target_handle_option;
+ handlers->handlers[2].mask = CL_TARGET;
+}
+
/* Parse command line options and set default flag values. Do minimal
options processing. The decoded options are in *DECODED_OPTIONS
- and *DECODED_OPTIONS_COUNT; settings go in OPTS, OPTS_SET and DC. */
+ and *DECODED_OPTIONS_COUNT; settings go in OPTS, OPTS_SET and DC;
+ the options are located at LOC. */
void
decode_options (struct gcc_options *opts, struct gcc_options *opts_set,
struct cl_decoded_option *decoded_options,
unsigned int decoded_options_count,
- diagnostic_context *dc)
+ location_t loc, diagnostic_context *dc)
{
struct cl_option_handlers handlers;
lang_mask = initial_lang_mask;
- handlers.unknown_option_callback = unknown_option_callback;
- handlers.wrong_lang_callback = complain_wrong_lang;
- handlers.post_handling_callback = post_handling_callback;
- handlers.num_handlers = 3;
- handlers.handlers[0].handler = lang_handle_option;
- handlers.handlers[0].mask = lang_mask;
- handlers.handlers[1].handler = common_handle_option;
- handlers.handlers[1].mask = CL_COMMON;
- handlers.handlers[2].handler = target_handle_option;
- handlers.handlers[2].mask = CL_TARGET;
-
- /* Enable -Werror=coverage-mismatch by default */
- enable_warning_as_error ("coverage-mismatch", 1, lang_mask, &handlers,
- dc);
+ set_default_handlers (&handlers);
+
+ /* Enable -Werror=coverage-mismatch by default. */
+ control_warning_option (OPT_Wcoverage_mismatch, (int) DK_ERROR, true,
+ loc, lang_mask,
+ &handlers, opts, opts_set, dc);
default_options_optimization (opts, opts_set,
decoded_options, decoded_options_count,
- lang_mask, &handlers, dc);
+ loc, lang_mask, &handlers, dc);
#ifdef ENABLE_LTO
/* Clear any options currently held for LTO. */
#endif
read_cmdline_options (opts, opts_set,
- decoded_options, decoded_options_count, lang_mask,
+ decoded_options, decoded_options_count,
+ loc, lang_mask,
&handlers, dc);
finish_options (opts, opts_set);
opts->x_flag_ipa_struct_reorg = 0;
}
- if (opts->x_flag_lto || opts->x_flag_whopr)
+ if (opts->x_flag_lto)
{
#ifdef ENABLE_LTO
opts->x_flag_generate_lto = 1;
error ("LTO support has not been enabled in this configuration");
#endif
}
- if (opts->x_flag_lto_partition_balanced || opts->x_flag_lto_partition_1to1)
+ if ((opts->x_flag_lto_partition_balanced != 0) + (opts->x_flag_lto_partition_1to1 != 0)
+ + (opts->x_flag_lto_partition_none != 0) >= 1)
{
- if (opts->x_flag_lto_partition_balanced
- && opts->x_flag_lto_partition_1to1)
+ if ((opts->x_flag_lto_partition_balanced != 0)
+ + (opts->x_flag_lto_partition_1to1 != 0)
+ + (opts->x_flag_lto_partition_none != 0) > 1)
error ("only one -flto-partition value can be specified");
- if (!opts->x_flag_whopr && !opts->x_flag_wpa && !opts->x_flag_ltrans)
- error ("-flto-partition has no effect without -fwhopr");
}
- /* Reconcile -flto and -fwhopr. Set additional flags as appropriate and
- check option consistency. */
- if (opts->x_flag_lto && opts->x_flag_whopr)
- error ("-flto and -fwhopr are mutually exclusive");
-
/* We initialize opts->x_flag_split_stack to -1 so that targets can set a
default value if they choose based on other options. */
if (opts->x_flag_split_stack == -1)
struct gcc_options *opts_set,
const struct cl_decoded_option *decoded,
unsigned int lang_mask, int kind ATTRIBUTE_UNUSED,
+ location_t loc,
const struct cl_option_handlers *handlers,
diagnostic_context *dc)
{
break;
case OPT_Werror_:
- enable_warning_as_error (arg, value, lang_mask, handlers, dc);
+ enable_warning_as_error (arg, value, lang_mask, handlers,
+ opts, opts_set, loc, dc);
break;
case OPT_Wlarger_than_:
dc->pedantic_errors = 1;
break;
- case OPT_fwhopr:
- opts->x_flag_whopr = "";
+ case OPT_flto:
+ opts->x_flag_lto = "";
break;
case OPT_w:
dc->dc_inhibit_warnings = true;
break;
+ case OPT_fmax_errors_:
+ dc->max_errors = value;
+ break;
+
case OPT_fuse_linker_plugin:
/* No-op. Used by the driver and passed to us because it starts with f.*/
break;
return true;
}
-/* Callback function, called when -Werror= enables a warning. */
-
-static void (*warning_as_error_callback) (int) = NULL;
-
-/* Register a callback for enable_warning_as_error calls. */
-
-void
-register_warning_as_error_callback (void (*callback) (int))
-{
- gcc_assert (warning_as_error_callback == NULL || callback == NULL);
- warning_as_error_callback = callback;
-}
-
/* Enable (or disable if VALUE is 0) a warning option ARG (language
- mask LANG_MASK, option handlers HANDLERS) as an error for
- diagnostic context DC (possibly NULL). This is used by
- -Werror=. */
+ mask LANG_MASK, option handlers HANDLERS) as an error for option
+ structures OPTS and OPTS_SET, diagnostic context DC (possibly
+ NULL), location LOC. This is used by -Werror=. */
-void
+static void
enable_warning_as_error (const char *arg, int value, unsigned int lang_mask,
const struct cl_option_handlers *handlers,
- diagnostic_context *dc)
+ struct gcc_options *opts,
+ struct gcc_options *opts_set,
+ location_t loc, diagnostic_context *dc)
{
char *new_option;
int option_index;
option_index = find_opt (new_option, lang_mask);
if (option_index == OPT_SPECIAL_unknown)
{
- error ("-Werror=%s: No option -%s", arg, new_option);
+ error ("-Werror=%s: no option -%s", arg, new_option);
}
else
{
- const struct cl_option *option = &cl_options[option_index];
const diagnostic_t kind = value ? DK_ERROR : DK_WARNING;
- if (option->alias_target != N_OPTS)
- option_index = option->alias_target;
- if (option_index == OPT_SPECIAL_ignore)
- return;
- if (dc)
- diagnostic_classify_diagnostic (dc, option_index, kind,
- UNKNOWN_LOCATION);
- if (kind == DK_ERROR)
- {
- const struct cl_option * const option = cl_options + option_index;
-
- /* -Werror=foo implies -Wfoo. */
- if (option->var_type == CLVC_BOOLEAN)
- handle_generated_option (&global_options, &global_options_set,
- option_index, NULL, value, lang_mask,
- (int)kind, handlers,
- dc);
-
- if (warning_as_error_callback)
- warning_as_error_callback (option_index);
- }
+ control_warning_option (option_index, (int) kind, value,
+ loc, lang_mask,
+ handlers, opts, opts_set, dc);
}
free (new_option);
}