#include "params.h"
#include "diagnostic.h"
#include "opts-diagnostic.h"
-#include "tm_p.h" /* For OPTIMIZATION_OPTIONS. */
#include "insn-attr.h" /* For INSN_SCHEDULING. */
#include "target.h"
#include "tree-pass.h"
const char **in_fnames;
unsigned num_in_fnames;
-static bool common_handle_option (size_t scode, const char *arg, int value,
+static bool common_handle_option (const struct cl_decoded_option *decoded,
unsigned int lang_mask, int kind,
const struct cl_option_handlers *handlers);
static void handle_param (const char *);
static char *write_langs (unsigned int lang_mask);
-static void complain_wrong_lang (const char *, const struct cl_option *,
+static void complain_wrong_lang (const struct cl_decoded_option *,
unsigned int lang_mask);
static void set_debug_level (enum debug_info_type type, int extended,
const char *arg);
return result;
}
-/* Complain that switch OPT_INDEX does not apply to this front end. */
+/* Complain that switch DECODED does not apply to this front end (mask
+ LANG_MASK). */
static void
-complain_wrong_lang (const char *text, const struct cl_option *option,
+complain_wrong_lang (const struct cl_decoded_option *decoded,
unsigned int lang_mask)
{
- char *ok_langs, *bad_lang;
+ const struct cl_option *option = &cl_options[decoded->opt_index];
+ const char *text = decoded->orig_option_with_args_text;
+ char *ok_langs = NULL, *bad_lang = NULL;
+ unsigned int opt_flags = option->flags;
if (!lang_hooks.complain_wrong_lang_p (option))
return;
- ok_langs = write_langs (option->flags);
- bad_lang = write_langs (lang_mask);
-
- /* Eventually this should become a hard error IMO. */
- warning (0, "command line option \"%s\" is valid for %s but not for %s",
- text, ok_langs, bad_lang);
+ opt_flags &= ((1U << cl_lang_count) - 1) | CL_DRIVER;
+ if (opt_flags != CL_DRIVER)
+ ok_langs = write_langs (opt_flags);
+ if (lang_mask != CL_DRIVER)
+ bad_lang = write_langs (lang_mask);
+
+ if (opt_flags == CL_DRIVER)
+ error ("command line option %qs is valid for the driver but not for %s",
+ text, bad_lang);
+ else if (lang_mask == CL_DRIVER)
+ gcc_unreachable ();
+ else
+ /* Eventually this should become a hard error IMO. */
+ warning (0, "command line option %qs is valid for %s but not for %s",
+ text, ok_langs, bad_lang);
free (ok_langs);
free (bad_lang);
input_location = saved_loc;
}
-/* Handle an unknown option ARG, returning true if an error should be
+/* Handle an unknown option DECODED, returning true if an error should be
given. */
static bool
-unknown_option_callback (const char *opt)
+unknown_option_callback (const struct cl_decoded_option *decoded)
{
- if (opt[1] == 'W' && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-')
+ const char *opt = decoded->arg;
+
+ if (opt[1] == 'W' && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-'
+ && !(decoded->errors & CL_ERR_NEGATIVE))
{
/* We don't generate warnings for unknown -Wno-* options unless
we issue diagnostics. */
return true;
}
-/* Note that an option (index OPT_INDEX, argument ARG, value VALUE)
- has been successfully handled with a handler for mask MASK. */
+/* Note that an option DECODED has been successfully handled with a
+ handler for mask MASK. */
static void
-post_handling_callback (size_t opt_index ATTRIBUTE_UNUSED,
- const char *arg ATTRIBUTE_UNUSED,
- int value ATTRIBUTE_UNUSED,
+post_handling_callback (const struct cl_decoded_option *decoded ATTRIBUTE_UNUSED,
unsigned int mask ATTRIBUTE_UNUSED)
{
#ifdef ENABLE_LTO
- lto_register_user_option (opt_index, arg, value, mask);
+ lto_register_user_option (decoded->opt_index, decoded->arg,
+ decoded->value, mask);
#endif
}
handle_option. */
static bool
-lang_handle_option (size_t opt_index, const char *arg, int value,
+lang_handle_option (const struct cl_decoded_option *decoded,
unsigned int lang_mask ATTRIBUTE_UNUSED, int kind,
const struct cl_option_handlers *handlers)
{
- return lang_hooks.handle_option (opt_index, arg, value, kind, handlers);
+ gcc_assert (decoded->canonical_option_num_elements <= 2);
+ return lang_hooks.handle_option (decoded->opt_index, decoded->arg,
+ decoded->value, kind, handlers);
}
/* Handle a back-end option; arguments and return value as for
handle_option. */
static bool
-target_handle_option (size_t opt_index, const char *arg, int value,
- unsigned int lang_mask ATTRIBUTE_UNUSED, int kind,
- const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
+target_handle_option (const struct cl_decoded_option *decoded,
+ unsigned int lang_mask ATTRIBUTE_UNUSED, int kind,
+ const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
{
+ gcc_assert (decoded->canonical_option_num_elements <= 2);
gcc_assert (kind == DK_UNSPECIFIED);
- return targetm.handle_option (opt_index, arg, value);
+ return targetm.handle_option (decoded->opt_index, decoded->arg,
+ decoded->value);
}
/* Handle FILENAME from the command line. */
char *s;
name = lang_hooks.decl_printable_name (fndecl, 0);
- for (i = 0;
- VEC_iterate (char_p, flag_instrument_functions_exclude_functions,
- i, s);
- ++i)
- {
- if (strstr (name, s) != NULL)
- return true;
- }
+ FOR_EACH_VEC_ELT (char_p, flag_instrument_functions_exclude_functions,
+ i, s)
+ if (strstr (name, s) != NULL)
+ return true;
}
if (VEC_length (char_p, flag_instrument_functions_exclude_files) > 0)
char *s;
name = DECL_SOURCE_FILE (fndecl);
- for (i = 0;
- VEC_iterate (char_p, flag_instrument_functions_exclude_files, i, s);
- ++i)
- {
- if (strstr (name, s) != NULL)
- return true;
- }
+ FOR_EACH_VEC_ELT (char_p, flag_instrument_functions_exclude_files, i, s)
+ if (strstr (name, s) != NULL)
+ return true;
}
return false;
else
lang_mask = initial_lang_mask;
- decode_cmdline_options_to_array (argc, argv, lang_mask,
+ decode_cmdline_options_to_array (argc, argv,
+ lang_mask | CL_COMMON | CL_TARGET,
decoded_options, decoded_options_count);
if (first_time_p)
/* Perform language-specific options initialization. */
flag_merge_constants = opt1;
flag_split_wide_types = opt1;
flag_tree_ccp = opt1;
+ flag_tree_bit_ccp = opt1;
flag_tree_dce = opt1;
flag_tree_dom = opt1;
flag_tree_dse = opt1;
/* -O3 optimizations. */
opt3 = (optimize >= 3);
+ flag_tree_loop_distribute_patterns = opt3;
flag_predictive_commoning = opt3;
flag_inline_functions = opt3;
flag_unswitch_loops = opt3;
set after target options have been processed. */
flag_short_enums = 2;
- /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
- modify it. */
+ /* Initialize target_flags before
+ targetm.target_option.optimization so the latter can modify
+ it. */
target_flags = targetm.default_target_flags;
/* Some targets have ABI-specified unwind tables. */
lto_clear_user_options ();
#endif
-#ifdef OPTIMIZATION_OPTIONS
/* Allow default optimizations to be specified on a per-machine basis. */
- OPTIMIZATION_OPTIONS (optimize, optimize_size);
-#endif
+ targetm.target_option.optimization (optimize, optimize_size);
read_cmdline_options (*decoded_options, *decoded_options_count, lang_mask,
&handlers);
check option consistency. */
if (flag_lto && flag_whopr)
error ("-flto and -fwhopr are mutually exclusive");
+
+ /* We initialize flag_split_stack to -1 so that targets can set a
+ default value if they choose based on other options. */
+ if (flag_split_stack == -1)
+ flag_split_stack = 0;
+ else
+ {
+ if (!targetm.supports_split_stack (true))
+ {
+ error ("%<-fsplit-stack%> is not supported by "
+ "this compiler configuration");
+ flag_split_stack = 0;
+ }
+ }
}
#define LEFT_COLUMN 27
if ((option->flags & exclude_flags) != 0)
continue;
+ /* The driver currently prints its own help text. */
+ if ((option->flags & CL_DRIVER) != 0
+ && (option->flags & (((1U << cl_lang_count) - 1)
+ | CL_COMMON | CL_TARGET)) == 0)
+ continue;
+
found = true;
/* Skip switches that have already been printed. */
if (printed[i])
switch (flag & include_flags)
{
case 0:
+ case CL_DRIVER:
break;
case CL_TARGET:
/* Handle target- and language-independent options. Return zero to
generate an "unknown option" message. Only options that need
extra handling need to be listed here; if you simply want
- VALUE assigned to a variable, it happens automatically. */
+ DECODED->value assigned to a variable, it happens automatically. */
static bool
-common_handle_option (size_t scode, const char *arg, int value,
+common_handle_option (const struct cl_decoded_option *decoded,
unsigned int lang_mask, int kind ATTRIBUTE_UNUSED,
const struct cl_option_handlers *handlers)
{
+ size_t scode = decoded->opt_index;
+ const char *arg = decoded->arg;
+ int value = decoded->value;
static bool verbose = false;
enum opt_code code = (enum opt_code) scode;
+ gcc_assert (decoded->canonical_option_num_elements <= 2);
+
switch (code)
{
case OPT__param:
verbose = true;
break;
- case OPT_fhelp:
case OPT__help:
{
unsigned int all_langs_mask = (1U << cl_lang_count) - 1;
print_specific_help (0, undoc_mask, all_langs_mask);
/* Then display any remaining, non-language options. */
for (i = CL_MIN_OPTION_CLASS; i <= CL_MAX_OPTION_CLASS; i <<= 1)
- print_specific_help (i, undoc_mask, 0);
+ if (i != CL_DRIVER)
+ print_specific_help (i, undoc_mask, 0);
exit_after_options = true;
break;
}
- case OPT_ftarget_help:
case OPT__target_help:
print_specific_help (CL_TARGET, CL_UNDOCUMENTED, 0);
exit_after_options = true;
targetm.help ();
break;
- case OPT_fhelp_:
case OPT__help_:
{
const char * a = arg;
break;
}
- case OPT_fversion:
case OPT__version:
exit_after_options = true;
break;
break;
case OPT_Wlarger_than_:
- /* This form corresponds to -Wlarger-than-.
- Kept for backward compatibility.
- Don't use it as the first argument of warning(). */
-
- case OPT_Wlarger_than_eq:
larger_than_size = value;
warn_larger_than = value != -1;
break;
break;
case OPT_aux_info:
- case OPT_aux_info_:
aux_info_file_name = arg;
flag_gen_aux_info = 1;
break;
break;
case OPT_finline_limit_:
- case OPT_finline_limit_eq:
set_param_value ("max-inline-insns-single", value / 2);
set_param_value ("max-inline-insns-auto", value / 2);
break;
warning (0, "unknown stack check parameter \"%s\"", arg);
break;
- case OPT_fstack_check:
- /* This is the same as the "specific" mode above. */
- if (value)
- flag_stack_check = STACK_CHECK_BUILTIN
- ? FULL_BUILTIN_STACK_CHECK
- : STACK_CHECK_STATIC_BUILTIN
- ? STATIC_BUILTIN_STACK_CHECK
- : GENERIC_STACK_CHECK;
- else
- flag_stack_check = NO_STACK_CHECK;
- break;
-
case OPT_fstack_limit:
/* The real switch is -fno-stack-limit. */
if (value)
global_dc->pedantic_errors = 1;
break;
+ case OPT_fwhopr_:
+ flag_whopr = arg;
+ break;
+
case OPT_fwhopr:
- flag_whopr = value;
+ flag_whopr = "";
break;
case OPT_w:
global_dc->inhibit_warnings = true;
break;
- case OPT_fsee:
- case OPT_fcse_skip_blocks:
- case OPT_floop_optimize:
- case OPT_frerun_loop_opt:
- case OPT_fsched2_use_traces:
- case OPT_fstrength_reduce:
- case OPT_ftree_store_copy_prop:
- case OPT_fforce_addr:
- case OPT_ftree_salias:
- case OPT_ftree_store_ccp:
- case OPT_Wunreachable_code:
- case OPT_fargument_alias:
- case OPT_fargument_noalias:
- case OPT_fargument_noalias_anything:
- case OPT_fargument_noalias_global:
- /* These are no-ops, preserved for backward compatibility. */
- break;
-
case OPT_fuse_linker_plugin:
/* No-op. Used by the driver and passed to us because it starts with f.*/
break;
}
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;
diagnostic_classify_diagnostic (global_dc, option_index, kind,
UNKNOWN_LOCATION);
if (kind == DK_ERROR)
/* -Werror=foo implies -Wfoo. */
if (option->var_type == CLVC_BOOLEAN)
- handle_option (option_index, arg, value, lang_mask, (int)kind,
- handlers);
+ handle_generated_option (option_index, NULL, value, lang_mask,
+ (int)kind, handlers);
if (warning_as_error_callback)
warning_as_error_callback (option_index);