aboutsummaryrefslogtreecommitdiff
path: root/gcc/opts-common.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2010-09-02 11:43:19 +0000
committerJoseph Myers <joseph@codesourcery.com>2010-09-02 11:43:19 +0000
commit427c456609762e869800f6c0ec129c5094c59296 (patch)
treeb73424a97ff306c8f1ae185b160c05e86be29bc0 /gcc/opts-common.c
parent1fb2385981035e5e01d79a00a64e52072ab5cf03 (diff)
* opts.h (struct cl_option): Add warn_message field.
(struct cl_decoded_option): Add warn_message field. * doc/options.texi (Ignore, Warn): Document. * opt-functions.awk (needs_state_p): Don't consider aliases or ignored options to need state saved. * optc-gen.awk: Handle Warn and Ignore. * opth-gen.awk: Output OPT_SPECIAL_ignore. * opts-common.c (decode_cmdline_option): Set warn_message field. Handle ignored options. (decode_cmdline_options_to_array, generate_option, generate_option_input_file): Set warn_message field. (read_cmdline_option): Generate warnings from warn_message field. Handle ignored options. * common.opt (Wunreachable-code, fargument-alias, fargument-noalias, fargument-noalias-global, fargument-noalias-anything, fcse-skip-blocks, fforce-addr, floop-optimize, frerun-loop-opt, fsched2-use-traces, fsee, fstrength-reduce, ftree-store-ccp, ftree-store-copy-prop, ftree-salias): Mark Ignore. * config/i386/i386.h (CC1_CPU_SPEC_1): Don't handle -mcpu, -mintel-syntax and -mno-intel-syntax here. * config/i386/i386.opt (mcpu=, mintel-syntax): Define as aliases using Warn. * opts.c (common_handle_option): Don't handle options marked as ignored. (enable_warning_as_error): Handle ignored options. c-family: * c.opt (Wimport, fall-virtual, falt-external-templates, fdefault-inline, fenum-int-equiv, fexternal-templates, fguiding-decls, fhonor-std, fhuge-objects, flabels-ok, fname-mangling-version-, fnew-abi, fnonnull-objects, foptional-diags, fsquangle, fstrict-prototype, fthis-is-variable, fvtable-gc, fvtable-thunks, fxref): Mark with Ignore and Warn as applicable. (fhandle-exceptions): Mark with Alias and Warn. * c-opts.c (c_common_handle_option): Don't handle options marked as ignored. po: * exgettext: Handle {} in operand of MissingArgError. Handle Warn. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@163771 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/opts-common.c')
-rw-r--r--gcc/opts-common.c108
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)
{