diff options
author | Joseph Myers <joseph@codesourcery.com> | 2010-08-11 11:04:43 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2010-08-11 11:04:43 +0100 |
commit | 481e1176d7614dcd519e50c488a155312280913e (patch) | |
tree | 48318d1dff4b32ecb5516a974e71f0e815752ba3 /gcc/opts.c | |
parent | 3abeaf8f89f246f481c869a09d0715a2762bde28 (diff) | |
download | gcc-481e1176d7614dcd519e50c488a155312280913e.tar.gz |
opts.h (struct cl_option_handler_func): Make handler take cl_decoded_option structure as parameter, not individual elements.
* opts.h (struct cl_option_handler_func): Make handler take
cl_decoded_option structure as parameter, not individual elements.
(struct cl_option_handlers): Make callbacks take cl_decoded_option
structure as parameter, not individual elements.
(handle_option): Take cl_decoded_option structure as parameter,
not individual elements.
(handle_generated_option): Declare.
* opts-common.c (handle_option): Take cl_decoded_option structure
as parameter, not individual elements. Update calls to callback
and handler functions.
(handle_generated_option): New.
(read_cmdline_option): Update calls to callback functions and
handle_option.
* opts.c (common_handle_option, complain_wrong_lang,
unknown_option_callback, post_handling_callback,
lang_handle_option, target_handle_option): Take cl_decoded_option
structure as parameter, not individual elements.
(lang_handle_option, target_handle_option, common_handle_option):
Assert option has at most one argument.
(enable_warning_as_error): Call handle_generated_option instead of
handle_option. Do not pass -Werror argument as argument of
generated option.
c-family:
* c-opts.c (c_common_handle_option): Call handle_generated_option
instead of handle_option.
From-SVN: r163095
Diffstat (limited to 'gcc/opts.c')
-rw-r--r-- | gcc/opts.c | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/gcc/opts.c b/gcc/opts.c index 967ad400278..6e528058750 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -372,12 +372,12 @@ bool flag_warn_unused_result = false; 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); @@ -410,11 +410,14 @@ write_langs (unsigned int mask) 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) { + const struct cl_option *option = &cl_options[decoded->opt_index]; + const char *text = decoded->orig_option_with_args_text; char *ok_langs, *bad_lang; if (!lang_hooks.complain_wrong_lang_p (option)) @@ -461,12 +464,14 @@ void print_ignored_options (void) 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) { + const char *opt = decoded->arg; + if (opt[1] == 'W' && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-') { /* We don't generate warnings for unknown -Wno-* options unless @@ -478,17 +483,16 @@ unknown_option_callback (const char *opt) 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 } @@ -496,23 +500,27 @@ post_handling_callback (size_t opt_index ATTRIBUTE_UNUSED, 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. */ @@ -1387,16 +1395,21 @@ print_specific_help (unsigned int include_flags, /* 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: @@ -2358,8 +2371,8 @@ enable_warning_as_error (const char *arg, int value, unsigned int lang_mask, /* -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); |