diff options
Diffstat (limited to 'gcc/opts-common.c')
-rw-r--r-- | gcc/opts-common.c | 108 |
1 files changed, 69 insertions, 39 deletions
diff --git a/gcc/opts-common.c b/gcc/opts-common.c index 07758967e6d..40822a7bde1 100644 --- a/gcc/opts-common.c +++ b/gcc/opts-common.c @@ -214,6 +214,7 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, char *p; const struct cl_option *option; int errors = 0; + const char *warn_message = NULL; bool separate_arg_flag; bool joined_arg_flag; @@ -254,6 +255,8 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, goto done; } + warn_message = option->warn_message; + /* Check to see if the option is disabled for this configuration. */ if (option->flags & CL_DISABLED) errors |= CL_ERR_DISABLED; @@ -300,55 +303,73 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, if (arg == NULL && (separate_arg_flag || joined_arg_flag)) errors |= CL_ERR_MISSING_ARG; - /* Is this option an alias? */ + /* Is this option an alias (or an ignored option, marked as an alias + of OPT_SPECIAL_ignore)? */ if (option->alias_target != N_OPTS) { size_t new_opt_index = option->alias_target; - const struct cl_option *new_option = &cl_options[new_opt_index]; - - /* The new option must not be an alias itself. */ - gcc_assert (new_option->alias_target == N_OPTS); - if (option->neg_alias_arg) + if (new_opt_index == OPT_SPECIAL_ignore) { - gcc_assert (option->alias_arg != NULL); - gcc_assert (arg == NULL); - if (value) - arg = option->alias_arg; - else - arg = option->neg_alias_arg; + gcc_assert (option->alias_arg == NULL); + gcc_assert (option->neg_alias_arg == NULL); + opt_index = new_opt_index; + arg = NULL; value = 1; } - else if (option->alias_arg) + else { - gcc_assert (value == 1); - gcc_assert (arg == NULL); - arg = option->alias_arg; - } + const struct cl_option *new_option = &cl_options[new_opt_index]; - opt_index = new_opt_index; - option = new_option; + /* The new option must not be an alias itself. */ + gcc_assert (new_option->alias_target == N_OPTS); - if (value == 0) - gcc_assert (!(option->flags & CL_REJECT_NEGATIVE)); + if (option->neg_alias_arg) + { + gcc_assert (option->alias_arg != NULL); + gcc_assert (arg == NULL); + if (value) + arg = option->alias_arg; + else + arg = option->neg_alias_arg; + value = 1; + } + else if (option->alias_arg) + { + gcc_assert (value == 1); + gcc_assert (arg == NULL); + arg = option->alias_arg; + } - /* Recompute what arguments are allowed. */ - separate_arg_flag = ((option->flags & CL_SEPARATE) - && !((option->flags & CL_NO_DRIVER_ARG) - && (lang_mask & CL_DRIVER))); - joined_arg_flag = (option->flags & CL_JOINED) != 0; + opt_index = new_opt_index; + option = new_option; - if (!(errors & CL_ERR_MISSING_ARG)) - { - if (separate_arg_flag || joined_arg_flag) - gcc_assert (arg != NULL); - else - gcc_assert (arg == NULL); - } + if (value == 0) + gcc_assert (!(option->flags & CL_REJECT_NEGATIVE)); + + /* Recompute what arguments are allowed. */ + separate_arg_flag = ((option->flags & CL_SEPARATE) + && !((option->flags & CL_NO_DRIVER_ARG) + && (lang_mask & CL_DRIVER))); + joined_arg_flag = (option->flags & CL_JOINED) != 0; + + if (!(errors & CL_ERR_MISSING_ARG)) + { + if (separate_arg_flag || joined_arg_flag) + gcc_assert (arg != NULL); + else + gcc_assert (arg == NULL); + } - /* Recheck for disabled options. */ - if (option->flags & CL_DISABLED) - errors |= CL_ERR_DISABLED; + /* Recheck for warnings and disabled options. */ + if (option->warn_message) + { + gcc_assert (warn_message == NULL); + warn_message = option->warn_message; + } + if (option->flags & CL_DISABLED) + errors |= CL_ERR_DISABLED; + } } /* Check if this is a switch for a different front end. */ @@ -370,6 +391,7 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, decoded->arg = arg; decoded->value = value; decoded->errors = errors; + decoded->warn_message = warn_message; if (opt_index == OPT_SPECIAL_unknown) { @@ -408,7 +430,7 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, else decoded->canonical_option[i] = NULL; } - if (opt_index != OPT_SPECIAL_unknown) + if (opt_index != OPT_SPECIAL_unknown && opt_index != OPT_SPECIAL_ignore) generate_canonical_option (opt_index, arg, value, decoded); decoded->orig_option_with_args_text = p = XNEWVEC (char, total_len); for (i = 0; i < result; i++) @@ -448,6 +470,7 @@ decode_cmdline_options_to_array (unsigned int argc, const char **argv, opt_array = XNEWVEC (struct cl_decoded_option, argc); opt_array[0].opt_index = OPT_SPECIAL_program_name; + opt_array[0].warn_message = NULL; opt_array[0].arg = argv[0]; opt_array[0].orig_option_with_args_text = argv[0]; opt_array[0].canonical_option_num_elements = 1; @@ -678,6 +701,7 @@ generate_option (size_t opt_index, const char *arg, int value, const struct cl_option *option = &cl_options[opt_index]; decoded->opt_index = opt_index; + decoded->warn_message = NULL; decoded->arg = arg; decoded->value = value; decoded->errors = (option_ok_for_language (option, lang_mask) @@ -709,6 +733,7 @@ generate_option_input_file (const char *file, struct cl_decoded_option *decoded) { decoded->opt_index = OPT_SPECIAL_input_file; + decoded->warn_message = NULL; decoded->arg = file; decoded->orig_option_with_args_text = file; decoded->canonical_option_num_elements = 1; @@ -729,7 +754,10 @@ read_cmdline_option (struct cl_decoded_option *decoded, const struct cl_option_handlers *handlers) { const struct cl_option *option; - const char *opt; + const char *opt = decoded->orig_option_with_args_text; + + if (decoded->warn_message) + warning (0, decoded->warn_message, opt); if (decoded->opt_index == OPT_SPECIAL_unknown) { @@ -738,8 +766,10 @@ read_cmdline_option (struct cl_decoded_option *decoded, return; } + if (decoded->opt_index == OPT_SPECIAL_ignore) + return; + option = &cl_options[decoded->opt_index]; - opt = decoded->orig_option_with_args_text; if (decoded->errors & CL_ERR_DISABLED) { |