aboutsummaryrefslogtreecommitdiff
path: root/gcc/opts.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2010-09-30 14:53:12 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2010-09-30 14:53:12 +0100
commit46625112d2613f6573f307c99b8e10c970748e15 (patch)
tree9e8ddd32df9fcfb0446877af547d5a2daa89da8b /gcc/opts.c
parent37ccfc46e8f0005bb8a3e08c189b95ca9948059a (diff)
downloadgcc-46625112d2613f6573f307c99b8e10c970748e15.zip
gcc-46625112d2613f6573f307c99b8e10c970748e15.tar.gz
gcc-46625112d2613f6573f307c99b8e10c970748e15.tar.bz2
opt-functions.awk (static_var): Update comment.
* opt-functions.awk (static_var): Update comment. (var_ref): Return offsetof expression or -1, not variable address. * optc-gen.awk: Generate structure field initializers instead of static variables. Expect -1 for missing variables instead of null pointer. Add gcc_options parameters to generated functions. * opth-gen.awk: Generate structure fields for static variables. Add gcc_options parameters to generated functions. * common.opt (optimize, optimize_size): Add variables. * config/i386/i386-c.c (ix86_pragma_target_parse): Pass &global_options to cl_target_option_restore. * config/i386/i386.c (ix86_valid_target_attribute_p): Pass &global_options to cl_optimization_restore, cl_target_option_save and cl_target_option_restore. (ix86_set_current_function): Pass &global_options to cl_target_option_restore. * config/pdp11/pdp11.h (optimize): Remove. * config/rs6000/rs6000.h (optimize): Remove. * config/sh/sh.h (optimize): Remove. * config/xtensa/xtensa.h (optimize): Remove. * coretypes.h (struct gcc_options): Declare. * diagnostic.c (diagnostic_initialize): Initialize context->option_state. (diagnostic_report_diagnostic): Pass option_state to option_enabled hook. * diagnostic.h (diagnostic_context.option_enabled): Add void * parameter. (diagnostic_context.option_state): New field. * final.c (final_start_function, final, final_scan_insn): Rename optimize parameter to optimize_p. * flags.h (optimize, optimize_size): Remove. * function.c (invoke_set_current_function_hook): Pass &global_options to cl_optimization_restore. * gcc.c (driver_handle_option): Take gcc_options parameter. Assert that it is &global_options. (process_command): Pass &global_options to read_cmdline_option. * ipa-pure-const.c (suggest_attribute): Pass &global_options to option_enabled. * lto-opts.c (lto_reissue_options): Use option_flag_var. Pass &global_options to set_option. * opts-common.c (handle_option, handle_generated_option, read_cmdline_option, set_option): Take explicit gcc_options parameters. Use option_flag_var. (option_flag_var): New. * opts.c (common_handle_option, lang_handle_option, target_handle_option): Take gcc_options parameter. Assert that it is &global_options. (read_cmdline_options): Pass &global_options to read_cmdline_option. (print_filtered_help): Use option_flag_var. Pass &global_options to option_enabled. (common_handle_option): Use option_flag_var. (option_enabled): Take opts parameter. Use option_flag_var. (get_option_state): Take gcc_options parameter. Use option_flag_var. Pass gcc_options parameter to option_enabled. (enable_warning_as_error): Pass &global_options to handle_generated_option. * opts.h (struct cl_option): Change flag_var to flag_var_offset. (cl_option_handler_func.handler): Take gcc_options parameter. (option_enabled, get_option_state, set_option, handle_option, handle_generated_option, read_cmdline_option): Take gcc_options parameters. * toplev.c (optimize, optimize_size): Remove. (print_switch_values): Pass &global_options to option_enabled. (option_affects_pch_p): Use option_flag_var. Pass &global_options to get_option_state. (general_init): Initialize global_dc->option_state. * tree.c (build_optimization_node): Pass &global_options to cl_optimization_save. (build_target_option_node): Pass &global_options to cl_target_option_save. c-family: * c-common.c (handle_optimize_attribute): Pass &global_options to cl_optimization_save and cl_optimization_restore. * c-opts.c (c_common_handle_option): Pass &global_options to handle_generated_option. * c-pragma.c (handle_pragma_diagnostic): Use option_flag_var. (handle_pragma_pop_options, handle_pragma_reset_options): Pass &global_options to cl_optimization_restore. From-SVN: r164751
Diffstat (limited to 'gcc/opts.c')
-rw-r--r--gcc/opts.c70
1 files changed, 43 insertions, 27 deletions
diff --git a/gcc/opts.c b/gcc/opts.c
index ff59fd2..2b2071e 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -376,7 +376,8 @@ bool flag_warn_unused_result = false;
const char **in_fnames;
unsigned num_in_fnames;
-static bool common_handle_option (const struct cl_decoded_option *decoded,
+static bool common_handle_option (struct gcc_options *opts,
+ const struct cl_decoded_option *decoded,
unsigned int lang_mask, int kind,
const struct cl_option_handlers *handlers);
static void handle_param (const char *);
@@ -515,10 +516,12 @@ post_handling_callback (const struct cl_decoded_option *decoded ATTRIBUTE_UNUSED
handle_option. */
static bool
-lang_handle_option (const struct cl_decoded_option *decoded,
+lang_handle_option (struct gcc_options *opts,
+ const struct cl_decoded_option *decoded,
unsigned int lang_mask ATTRIBUTE_UNUSED, int kind,
const struct cl_option_handlers *handlers)
{
+ gcc_assert (opts == &global_options);
gcc_assert (decoded->canonical_option_num_elements <= 2);
return lang_hooks.handle_option (decoded->opt_index, decoded->arg,
decoded->value, kind, handlers);
@@ -528,10 +531,12 @@ lang_handle_option (const struct cl_decoded_option *decoded,
handle_option. */
static bool
-target_handle_option (const struct cl_decoded_option *decoded,
+target_handle_option (struct gcc_options *opts,
+ const struct cl_decoded_option *decoded,
unsigned int lang_mask ATTRIBUTE_UNUSED, int kind,
const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
{
+ gcc_assert (opts == &global_options);
gcc_assert (decoded->canonical_option_num_elements <= 2);
gcc_assert (kind == DK_UNSPECIFIED);
return targetm.handle_option (decoded->opt_index, decoded->arg,
@@ -644,7 +649,8 @@ read_cmdline_options (struct cl_decoded_option *decoded_options,
continue;
}
- read_cmdline_option (decoded_options + i, lang_mask, handlers);
+ read_cmdline_option (&global_options, decoded_options + i,
+ lang_mask, handlers);
}
}
@@ -1254,28 +1260,30 @@ print_filtered_help (unsigned int include_flags,
with an option to be an indication of its current setting. */
if (!quiet_flag)
{
+ void *flag_var = option_flag_var (i, &global_options);
+
if (len < (LEFT_COLUMN + 2))
strcpy (new_help, "\t\t");
else
strcpy (new_help, "\t");
- if (option->flag_var != NULL)
+ if (flag_var != NULL)
{
if (option->flags & CL_JOINED)
{
if (option->var_type == CLVC_STRING)
{
- if (* (const char **) option->flag_var != NULL)
+ if (* (const char **) flag_var != NULL)
snprintf (new_help + strlen (new_help),
sizeof (new_help) - strlen (new_help),
- * (const char **) option->flag_var);
+ * (const char **) flag_var);
}
else
sprintf (new_help + strlen (new_help),
- "%#x", * (int *) option->flag_var);
+ "%#x", * (int *) flag_var);
}
else
- strcat (new_help, option_enabled (i)
+ strcat (new_help, option_enabled (i, &global_options)
? _("[enabled]") : _("[disabled]"));
}
@@ -1423,7 +1431,8 @@ print_specific_help (unsigned int include_flags,
DECODED->value assigned to a variable, it happens automatically. */
static bool
-common_handle_option (const struct cl_decoded_option *decoded,
+common_handle_option (struct gcc_options *opts,
+ const struct cl_decoded_option *decoded,
unsigned int lang_mask, int kind ATTRIBUTE_UNUSED,
const struct cl_option_handlers *handlers)
{
@@ -1433,6 +1442,7 @@ common_handle_option (const struct cl_decoded_option *decoded,
static bool verbose = false;
enum opt_code code = (enum opt_code) scode;
+ gcc_assert (opts == &global_options);
gcc_assert (decoded->canonical_option_num_elements <= 2);
switch (code)
@@ -2102,7 +2112,7 @@ common_handle_option (const struct cl_decoded_option *decoded,
default:
/* If the flag was handled in a standard way, assume the lack of
processing here is intentional. */
- gcc_assert (cl_options[scode].flag_var);
+ gcc_assert (option_flag_var (scode, opts));
break;
}
@@ -2258,28 +2268,30 @@ set_debug_level (enum debug_info_type type, int extended, const char *arg)
}
}
-/* Return 1 if OPTION is enabled, 0 if it is disabled, or -1 if it isn't
- a simple on-off switch. */
+/* Return 1 if option OPT_IDX is enabled in OPTS, 0 if it is disabled,
+ or -1 if it isn't a simple on-off switch. */
int
-option_enabled (int opt_idx)
+option_enabled (int opt_idx, void *opts)
{
const struct cl_option *option = &(cl_options[opt_idx]);
+ struct gcc_options *optsg = (struct gcc_options *) opts;
+ void *flag_var = option_flag_var (opt_idx, optsg);
- if (option->flag_var)
+ if (flag_var)
switch (option->var_type)
{
case CLVC_BOOLEAN:
- return *(int *) option->flag_var != 0;
+ return *(int *) flag_var != 0;
case CLVC_EQUAL:
- return *(int *) option->flag_var == option->var_value;
+ return *(int *) flag_var == option->var_value;
case CLVC_BIT_CLEAR:
- return (*(int *) option->flag_var & option->var_value) == 0;
+ return (*(int *) flag_var & option->var_value) == 0;
case CLVC_BIT_SET:
- return (*(int *) option->flag_var & option->var_value) != 0;
+ return (*(int *) flag_var & option->var_value) != 0;
case CLVC_STRING:
break;
@@ -2287,32 +2299,35 @@ option_enabled (int opt_idx)
return -1;
}
-/* Fill STATE with the current state of option OPTION. Return true if
- there is some state to store. */
+/* Fill STATE with the current state of option OPTION in OPTS. Return
+ true if there is some state to store. */
bool
-get_option_state (int option, struct cl_option_state *state)
+get_option_state (struct gcc_options *opts, int option,
+ struct cl_option_state *state)
{
- if (cl_options[option].flag_var == 0)
+ void *flag_var = option_flag_var (option, opts);
+
+ if (flag_var == 0)
return false;
switch (cl_options[option].var_type)
{
case CLVC_BOOLEAN:
case CLVC_EQUAL:
- state->data = cl_options[option].flag_var;
+ state->data = flag_var;
state->size = sizeof (int);
break;
case CLVC_BIT_CLEAR:
case CLVC_BIT_SET:
- state->ch = option_enabled (option);
+ state->ch = option_enabled (option, opts);
state->data = &state->ch;
state->size = 1;
break;
case CLVC_STRING:
- state->data = *(const char **) cl_options[option].flag_var;
+ state->data = *(const char **) flag_var;
if (state->data == 0)
state->data = "";
state->size = strlen ((const char *) state->data) + 1;
@@ -2369,7 +2384,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_generated_option (option_index, NULL, value, lang_mask,
+ handle_generated_option (&global_options, option_index,
+ NULL, value, lang_mask,
(int)kind, handlers);
if (warning_as_error_callback)