Commit 130fcab0 by Martin Liska Committed by Martin Liska

Fix --help=target (PR other/39851).

2017-08-29  Martin Liska  <mliska@suse.cz>

	PR other/39851
	* gcc.c (driver_handle_option): Add new argument.
	* opts-common.c (handle_option): Pass
	target_option_override_hook.
	* opts-global.c (lang_handle_option): Add new option.
	(set_default_handlers):  Add new argument.
	(decode_options): Likewise.
	* opts.c (target_handle_option): Likewise.
	(common_handle_option): Call target_option_override_hook.
	* opts.h (struct cl_option_handler_func): Add hook for
	target option override.
	(struct cl_option_handlers): Likewise.
	(set_default_handlers): Add new argument.
	(decode_options): Likewise.
	(common_handle_option): Likewise.
	(target_handle_option): Likewise.
	* toplev.c (toplev::main): Pass targetm.target_option.override
	hook.
2017-08-29  Martin Liska  <mliska@suse.cz>

	PR other/39851
	* c-common.c (parse_optimize_options): Add argument to function
	call.
	* c-pragma.c (handle_pragma_diagnostic): Likewise.

From-SVN: r251400
parent faa5399b
2017-08-29 Martin Liska <mliska@suse.cz>
PR other/39851
* gcc.c (driver_handle_option): Add new argument.
* opts-common.c (handle_option): Pass
target_option_override_hook.
* opts-global.c (lang_handle_option): Add new option.
(set_default_handlers): Add new argument.
(decode_options): Likewise.
* opts.c (target_handle_option): Likewise.
(common_handle_option): Call target_option_override_hook.
* opts.h (struct cl_option_handler_func): Add hook for
target option override.
(struct cl_option_handlers): Likewise.
(set_default_handlers): Add new argument.
(decode_options): Likewise.
(common_handle_option): Likewise.
(target_handle_option): Likewise.
* toplev.c (toplev::main): Pass targetm.target_option.override
hook.
2017-08-29 Richard Biener <rguenther@suse.de> 2017-08-29 Richard Biener <rguenther@suse.de>
Dominik Infuehr <dominik.infuehr@theobroma-systems.com> Dominik Infuehr <dominik.infuehr@theobroma-systems.com>
......
2017-08-29 Martin Liska <mliska@suse.cz>
PR other/39851
* c-common.c (parse_optimize_options): Add argument to function
call.
* c-pragma.c (handle_pragma_diagnostic): Likewise.
2017-08-24 David Malcolm <dmalcolm@redhat.com> 2017-08-24 David Malcolm <dmalcolm@redhat.com>
* c-lex.c (interpret_float): Use token location * c-lex.c (interpret_float): Use token location
......
...@@ -5497,7 +5497,7 @@ parse_optimize_options (tree args, bool attr_p) ...@@ -5497,7 +5497,7 @@ parse_optimize_options (tree args, bool attr_p)
/* And apply them. */ /* And apply them. */
decode_options (&global_options, &global_options_set, decode_options (&global_options, &global_options_set,
decoded_options, decoded_options_count, decoded_options, decoded_options_count,
input_location, global_dc); input_location, global_dc, NULL);
targetm.override_options_after_change(); targetm.override_options_after_change();
......
...@@ -815,7 +815,7 @@ handle_pragma_diagnostic(cpp_reader *ARG_UNUSED(dummy)) ...@@ -815,7 +815,7 @@ handle_pragma_diagnostic(cpp_reader *ARG_UNUSED(dummy))
} }
struct cl_option_handlers handlers; struct cl_option_handlers handlers;
set_default_handlers (&handlers); set_default_handlers (&handlers, NULL);
const char *arg = NULL; const char *arg = NULL;
if (cl_options[option_index].flags & CL_JOINED) if (cl_options[option_index].flags & CL_JOINED)
arg = option_string + 1 + cl_options[option_index].opt_len; arg = option_string + 1 + cl_options[option_index].opt_len;
......
...@@ -3769,7 +3769,8 @@ driver_handle_option (struct gcc_options *opts, ...@@ -3769,7 +3769,8 @@ driver_handle_option (struct gcc_options *opts,
unsigned int lang_mask ATTRIBUTE_UNUSED, int kind, unsigned int lang_mask ATTRIBUTE_UNUSED, int kind,
location_t loc, location_t loc,
const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED, const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED,
diagnostic_context *dc) diagnostic_context *dc,
void (*) (void))
{ {
size_t opt_index = decoded->opt_index; size_t opt_index = decoded->opt_index;
const char *arg = decoded->arg; const char *arg = decoded->arg;
......
...@@ -993,7 +993,8 @@ handle_option (struct gcc_options *opts, ...@@ -993,7 +993,8 @@ handle_option (struct gcc_options *opts,
{ {
if (!handlers->handlers[i].handler (opts, opts_set, decoded, if (!handlers->handlers[i].handler (opts, opts_set, decoded,
lang_mask, kind, loc, lang_mask, kind, loc,
handlers, dc)) handlers, dc,
handlers->target_option_override_hook))
return false; return false;
} }
......
...@@ -169,7 +169,8 @@ lang_handle_option (struct gcc_options *opts, ...@@ -169,7 +169,8 @@ lang_handle_option (struct gcc_options *opts,
unsigned int lang_mask ATTRIBUTE_UNUSED, int kind, unsigned int lang_mask ATTRIBUTE_UNUSED, int kind,
location_t loc, location_t loc,
const struct cl_option_handlers *handlers, const struct cl_option_handlers *handlers,
diagnostic_context *dc) diagnostic_context *dc,
void (*) (void))
{ {
gcc_assert (opts == &global_options); gcc_assert (opts == &global_options);
gcc_assert (opts_set == &global_options_set); gcc_assert (opts_set == &global_options_set);
...@@ -269,10 +270,12 @@ decode_cmdline_options_to_array_default_mask (unsigned int argc, ...@@ -269,10 +270,12 @@ decode_cmdline_options_to_array_default_mask (unsigned int argc,
/* Set *HANDLERS to the default set of option handlers for use in the /* Set *HANDLERS to the default set of option handlers for use in the
compilers proper (not the driver). */ compilers proper (not the driver). */
void void
set_default_handlers (struct cl_option_handlers *handlers) set_default_handlers (struct cl_option_handlers *handlers,
void (*target_option_override_hook) (void))
{ {
handlers->unknown_option_callback = unknown_option_callback; handlers->unknown_option_callback = unknown_option_callback;
handlers->wrong_lang_callback = complain_wrong_lang; handlers->wrong_lang_callback = complain_wrong_lang;
handlers->target_option_override_hook = target_option_override_hook;
handlers->num_handlers = 3; handlers->num_handlers = 3;
handlers->handlers[0].handler = lang_handle_option; handlers->handlers[0].handler = lang_handle_option;
handlers->handlers[0].mask = initial_lang_mask; handlers->handlers[0].mask = initial_lang_mask;
...@@ -290,7 +293,8 @@ void ...@@ -290,7 +293,8 @@ void
decode_options (struct gcc_options *opts, struct gcc_options *opts_set, decode_options (struct gcc_options *opts, struct gcc_options *opts_set,
struct cl_decoded_option *decoded_options, struct cl_decoded_option *decoded_options,
unsigned int decoded_options_count, unsigned int decoded_options_count,
location_t loc, diagnostic_context *dc) location_t loc, diagnostic_context *dc,
void (*target_option_override_hook) (void))
{ {
struct cl_option_handlers handlers; struct cl_option_handlers handlers;
...@@ -298,7 +302,7 @@ decode_options (struct gcc_options *opts, struct gcc_options *opts_set, ...@@ -298,7 +302,7 @@ decode_options (struct gcc_options *opts, struct gcc_options *opts_set,
lang_mask = initial_lang_mask; lang_mask = initial_lang_mask;
set_default_handlers (&handlers); set_default_handlers (&handlers, target_option_override_hook);
default_options_optimization (opts, opts_set, default_options_optimization (opts, opts_set,
decoded_options, decoded_options_count, decoded_options, decoded_options_count,
......
...@@ -217,7 +217,7 @@ target_handle_option (struct gcc_options *opts, ...@@ -217,7 +217,7 @@ target_handle_option (struct gcc_options *opts,
unsigned int lang_mask ATTRIBUTE_UNUSED, int kind, unsigned int lang_mask ATTRIBUTE_UNUSED, int kind,
location_t loc, location_t loc,
const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED, const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED,
diagnostic_context *dc) diagnostic_context *dc, void (*) (void))
{ {
gcc_assert (dc == global_dc); gcc_assert (dc == global_dc);
gcc_assert (kind == DK_UNSPECIFIED); gcc_assert (kind == DK_UNSPECIFIED);
...@@ -1716,7 +1716,8 @@ common_handle_option (struct gcc_options *opts, ...@@ -1716,7 +1716,8 @@ common_handle_option (struct gcc_options *opts,
unsigned int lang_mask, int kind ATTRIBUTE_UNUSED, unsigned int lang_mask, int kind ATTRIBUTE_UNUSED,
location_t loc, location_t loc,
const struct cl_option_handlers *handlers, const struct cl_option_handlers *handlers,
diagnostic_context *dc) diagnostic_context *dc,
void (*target_option_override_hook) (void))
{ {
size_t scode = decoded->opt_index; size_t scode = decoded->opt_index;
const char *arg = decoded->arg; const char *arg = decoded->arg;
...@@ -1743,6 +1744,7 @@ common_handle_option (struct gcc_options *opts, ...@@ -1743,6 +1744,7 @@ common_handle_option (struct gcc_options *opts,
undoc_mask = ((opts->x_verbose_flag | opts->x_extra_warnings) undoc_mask = ((opts->x_verbose_flag | opts->x_extra_warnings)
? 0 ? 0
: CL_UNDOCUMENTED); : CL_UNDOCUMENTED);
target_option_override_hook ();
/* First display any single language specific options. */ /* First display any single language specific options. */
for (i = 0; i < cl_lang_count; i++) for (i = 0; i < cl_lang_count; i++)
print_specific_help print_specific_help
...@@ -1762,6 +1764,7 @@ common_handle_option (struct gcc_options *opts, ...@@ -1762,6 +1764,7 @@ common_handle_option (struct gcc_options *opts,
if (lang_mask == CL_DRIVER) if (lang_mask == CL_DRIVER)
break; break;
target_option_override_hook ();
print_specific_help (CL_TARGET, CL_UNDOCUMENTED, 0, opts, lang_mask); print_specific_help (CL_TARGET, CL_UNDOCUMENTED, 0, opts, lang_mask);
opts->x_exit_after_options = true; opts->x_exit_after_options = true;
break; break;
...@@ -1888,8 +1891,11 @@ common_handle_option (struct gcc_options *opts, ...@@ -1888,8 +1891,11 @@ common_handle_option (struct gcc_options *opts,
} }
if (include_flags) if (include_flags)
{
target_option_override_hook ();
print_specific_help (include_flags, exclude_flags, 0, opts, print_specific_help (include_flags, exclude_flags, 0, opts,
lang_mask); lang_mask);
}
opts->x_exit_after_options = true; opts->x_exit_after_options = true;
break; break;
} }
......
...@@ -272,7 +272,8 @@ struct cl_option_handler_func ...@@ -272,7 +272,8 @@ struct cl_option_handler_func
const struct cl_decoded_option *decoded, const struct cl_decoded_option *decoded,
unsigned int lang_mask, int kind, location_t loc, unsigned int lang_mask, int kind, location_t loc,
const struct cl_option_handlers *handlers, const struct cl_option_handlers *handlers,
diagnostic_context *dc); diagnostic_context *dc,
void (*target_option_override_hook) (void));
/* The mask that must have some bit in common with the flags for the /* The mask that must have some bit in common with the flags for the
option for this particular handler to be used. */ option for this particular handler to be used. */
...@@ -294,6 +295,9 @@ struct cl_option_handlers ...@@ -294,6 +295,9 @@ struct cl_option_handlers
void (*wrong_lang_callback) (const struct cl_decoded_option *decoded, void (*wrong_lang_callback) (const struct cl_decoded_option *decoded,
unsigned int lang_mask); unsigned int lang_mask);
/* Target option override hook. */
void (*target_option_override_hook) (void);
/* The number of individual handlers. */ /* The number of individual handlers. */
size_t num_handlers; size_t num_handlers;
...@@ -338,13 +342,15 @@ extern void decode_cmdline_options_to_array_default_mask (unsigned int argc, ...@@ -338,13 +342,15 @@ extern void decode_cmdline_options_to_array_default_mask (unsigned int argc,
const char **argv, const char **argv,
struct cl_decoded_option **decoded_options, struct cl_decoded_option **decoded_options,
unsigned int *decoded_options_count); unsigned int *decoded_options_count);
extern void set_default_handlers (struct cl_option_handlers *handlers); extern void set_default_handlers (struct cl_option_handlers *handlers,
void (*target_option_override_hook) (void));
extern void decode_options (struct gcc_options *opts, extern void decode_options (struct gcc_options *opts,
struct gcc_options *opts_set, struct gcc_options *opts_set,
struct cl_decoded_option *decoded_options, struct cl_decoded_option *decoded_options,
unsigned int decoded_options_count, unsigned int decoded_options_count,
location_t loc, location_t loc,
diagnostic_context *dc); diagnostic_context *dc,
void (*target_option_override_hook) (void));
extern int option_enabled (int opt_idx, void *opts); extern int option_enabled (int opt_idx, void *opts);
extern bool get_option_state (struct gcc_options *, int, extern bool get_option_state (struct gcc_options *, int,
struct cl_option_state *); struct cl_option_state *);
...@@ -391,14 +397,16 @@ extern bool common_handle_option (struct gcc_options *opts, ...@@ -391,14 +397,16 @@ extern bool common_handle_option (struct gcc_options *opts,
unsigned int lang_mask, int kind, unsigned int lang_mask, int kind,
location_t loc, location_t loc,
const struct cl_option_handlers *handlers, const struct cl_option_handlers *handlers,
diagnostic_context *dc); diagnostic_context *dc,
void (*target_option_override_hook) (void));
extern bool target_handle_option (struct gcc_options *opts, extern bool target_handle_option (struct gcc_options *opts,
struct gcc_options *opts_set, struct gcc_options *opts_set,
const struct cl_decoded_option *decoded, const struct cl_decoded_option *decoded,
unsigned int lang_mask, int kind, unsigned int lang_mask, int kind,
location_t loc, location_t loc,
const struct cl_option_handlers *handlers, const struct cl_option_handlers *handlers,
diagnostic_context *dc); diagnostic_context *dc,
void (*target_option_override_hook) (void));
extern void finish_options (struct gcc_options *opts, extern void finish_options (struct gcc_options *opts,
struct gcc_options *opts_set, struct gcc_options *opts_set,
location_t loc); location_t loc);
......
...@@ -2149,7 +2149,8 @@ toplev::main (int argc, char **argv) ...@@ -2149,7 +2149,8 @@ toplev::main (int argc, char **argv)
enough to default flags appropriately. */ enough to default flags appropriately. */
decode_options (&global_options, &global_options_set, decode_options (&global_options, &global_options_set,
save_decoded_options, save_decoded_options_count, save_decoded_options, save_decoded_options_count,
UNKNOWN_LOCATION, global_dc); UNKNOWN_LOCATION, global_dc,
targetm.target_option.override);
handle_common_deferred_options (); handle_common_deferred_options ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment