Skip to content

Commit 9810238

Browse files
author
marxin
committed
Fix --help=target (PR other/39851).
2017-08-29 Martin Liska <[email protected]> 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 <[email protected]> PR other/39851 * c-common.c (parse_optimize_options): Add argument to function call. * c-pragma.c (handle_pragma_diagnostic): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@251400 138bc75d-0d04-0410-961f-82ee72b054a4
1 parent 1c19938 commit 9810238

File tree

10 files changed

+67
-18
lines changed

10 files changed

+67
-18
lines changed

gcc/ChangeLog

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
2017-08-29 Martin Liska <[email protected]>
2+
3+
PR other/39851
4+
* gcc.c (driver_handle_option): Add new argument.
5+
* opts-common.c (handle_option): Pass
6+
target_option_override_hook.
7+
* opts-global.c (lang_handle_option): Add new option.
8+
(set_default_handlers): Add new argument.
9+
(decode_options): Likewise.
10+
* opts.c (target_handle_option): Likewise.
11+
(common_handle_option): Call target_option_override_hook.
12+
* opts.h (struct cl_option_handler_func): Add hook for
13+
target option override.
14+
(struct cl_option_handlers): Likewise.
15+
(set_default_handlers): Add new argument.
16+
(decode_options): Likewise.
17+
(common_handle_option): Likewise.
18+
(target_handle_option): Likewise.
19+
* toplev.c (toplev::main): Pass targetm.target_option.override
20+
hook.
21+
122
2017-08-29 Richard Biener <[email protected]>
223
Dominik Infuehr <[email protected]>
324

gcc/c-family/ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2017-08-29 Martin Liska <[email protected]>
2+
3+
PR other/39851
4+
* c-common.c (parse_optimize_options): Add argument to function
5+
call.
6+
* c-pragma.c (handle_pragma_diagnostic): Likewise.
7+
18
2017-08-24 David Malcolm <[email protected]>
29

310
* c-lex.c (interpret_float): Use token location

gcc/c-family/c-common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5497,7 +5497,7 @@ parse_optimize_options (tree args, bool attr_p)
54975497
/* And apply them. */
54985498
decode_options (&global_options, &global_options_set,
54995499
decoded_options, decoded_options_count,
5500-
input_location, global_dc);
5500+
input_location, global_dc, NULL);
55015501

55025502
targetm.override_options_after_change();
55035503

gcc/c-family/c-pragma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ handle_pragma_diagnostic(cpp_reader *ARG_UNUSED(dummy))
815815
}
816816

817817
struct cl_option_handlers handlers;
818-
set_default_handlers (&handlers);
818+
set_default_handlers (&handlers, NULL);
819819
const char *arg = NULL;
820820
if (cl_options[option_index].flags & CL_JOINED)
821821
arg = option_string + 1 + cl_options[option_index].opt_len;

gcc/gcc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3769,7 +3769,8 @@ driver_handle_option (struct gcc_options *opts,
37693769
unsigned int lang_mask ATTRIBUTE_UNUSED, int kind,
37703770
location_t loc,
37713771
const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED,
3772-
diagnostic_context *dc)
3772+
diagnostic_context *dc,
3773+
void (*) (void))
37733774
{
37743775
size_t opt_index = decoded->opt_index;
37753776
const char *arg = decoded->arg;

gcc/opts-common.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,8 @@ handle_option (struct gcc_options *opts,
993993
{
994994
if (!handlers->handlers[i].handler (opts, opts_set, decoded,
995995
lang_mask, kind, loc,
996-
handlers, dc))
996+
handlers, dc,
997+
handlers->target_option_override_hook))
997998
return false;
998999
}
9991000

gcc/opts-global.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ lang_handle_option (struct gcc_options *opts,
169169
unsigned int lang_mask ATTRIBUTE_UNUSED, int kind,
170170
location_t loc,
171171
const struct cl_option_handlers *handlers,
172-
diagnostic_context *dc)
172+
diagnostic_context *dc,
173+
void (*) (void))
173174
{
174175
gcc_assert (opts == &global_options);
175176
gcc_assert (opts_set == &global_options_set);
@@ -269,10 +270,12 @@ decode_cmdline_options_to_array_default_mask (unsigned int argc,
269270
/* Set *HANDLERS to the default set of option handlers for use in the
270271
compilers proper (not the driver). */
271272
void
272-
set_default_handlers (struct cl_option_handlers *handlers)
273+
set_default_handlers (struct cl_option_handlers *handlers,
274+
void (*target_option_override_hook) (void))
273275
{
274276
handlers->unknown_option_callback = unknown_option_callback;
275277
handlers->wrong_lang_callback = complain_wrong_lang;
278+
handlers->target_option_override_hook = target_option_override_hook;
276279
handlers->num_handlers = 3;
277280
handlers->handlers[0].handler = lang_handle_option;
278281
handlers->handlers[0].mask = initial_lang_mask;
@@ -290,15 +293,16 @@ void
290293
decode_options (struct gcc_options *opts, struct gcc_options *opts_set,
291294
struct cl_decoded_option *decoded_options,
292295
unsigned int decoded_options_count,
293-
location_t loc, diagnostic_context *dc)
296+
location_t loc, diagnostic_context *dc,
297+
void (*target_option_override_hook) (void))
294298
{
295299
struct cl_option_handlers handlers;
296300

297301
unsigned int lang_mask;
298302

299303
lang_mask = initial_lang_mask;
300304

301-
set_default_handlers (&handlers);
305+
set_default_handlers (&handlers, target_option_override_hook);
302306

303307
default_options_optimization (opts, opts_set,
304308
decoded_options, decoded_options_count,

gcc/opts.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ target_handle_option (struct gcc_options *opts,
217217
unsigned int lang_mask ATTRIBUTE_UNUSED, int kind,
218218
location_t loc,
219219
const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED,
220-
diagnostic_context *dc)
220+
diagnostic_context *dc, void (*) (void))
221221
{
222222
gcc_assert (dc == global_dc);
223223
gcc_assert (kind == DK_UNSPECIFIED);
@@ -1716,7 +1716,8 @@ common_handle_option (struct gcc_options *opts,
17161716
unsigned int lang_mask, int kind ATTRIBUTE_UNUSED,
17171717
location_t loc,
17181718
const struct cl_option_handlers *handlers,
1719-
diagnostic_context *dc)
1719+
diagnostic_context *dc,
1720+
void (*target_option_override_hook) (void))
17201721
{
17211722
size_t scode = decoded->opt_index;
17221723
const char *arg = decoded->arg;
@@ -1743,6 +1744,7 @@ common_handle_option (struct gcc_options *opts,
17431744
undoc_mask = ((opts->x_verbose_flag | opts->x_extra_warnings)
17441745
? 0
17451746
: CL_UNDOCUMENTED);
1747+
target_option_override_hook ();
17461748
/* First display any single language specific options. */
17471749
for (i = 0; i < cl_lang_count; i++)
17481750
print_specific_help
@@ -1762,6 +1764,7 @@ common_handle_option (struct gcc_options *opts,
17621764
if (lang_mask == CL_DRIVER)
17631765
break;
17641766

1767+
target_option_override_hook ();
17651768
print_specific_help (CL_TARGET, CL_UNDOCUMENTED, 0, opts, lang_mask);
17661769
opts->x_exit_after_options = true;
17671770
break;
@@ -1888,8 +1891,11 @@ common_handle_option (struct gcc_options *opts,
18881891
}
18891892

18901893
if (include_flags)
1891-
print_specific_help (include_flags, exclude_flags, 0, opts,
1892-
lang_mask);
1894+
{
1895+
target_option_override_hook ();
1896+
print_specific_help (include_flags, exclude_flags, 0, opts,
1897+
lang_mask);
1898+
}
18931899
opts->x_exit_after_options = true;
18941900
break;
18951901
}

gcc/opts.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ struct cl_option_handler_func
272272
const struct cl_decoded_option *decoded,
273273
unsigned int lang_mask, int kind, location_t loc,
274274
const struct cl_option_handlers *handlers,
275-
diagnostic_context *dc);
275+
diagnostic_context *dc,
276+
void (*target_option_override_hook) (void));
276277

277278
/* The mask that must have some bit in common with the flags for the
278279
option for this particular handler to be used. */
@@ -294,6 +295,9 @@ struct cl_option_handlers
294295
void (*wrong_lang_callback) (const struct cl_decoded_option *decoded,
295296
unsigned int lang_mask);
296297

298+
/* Target option override hook. */
299+
void (*target_option_override_hook) (void);
300+
297301
/* The number of individual handlers. */
298302
size_t num_handlers;
299303

@@ -338,13 +342,15 @@ extern void decode_cmdline_options_to_array_default_mask (unsigned int argc,
338342
const char **argv,
339343
struct cl_decoded_option **decoded_options,
340344
unsigned int *decoded_options_count);
341-
extern void set_default_handlers (struct cl_option_handlers *handlers);
345+
extern void set_default_handlers (struct cl_option_handlers *handlers,
346+
void (*target_option_override_hook) (void));
342347
extern void decode_options (struct gcc_options *opts,
343348
struct gcc_options *opts_set,
344349
struct cl_decoded_option *decoded_options,
345350
unsigned int decoded_options_count,
346351
location_t loc,
347-
diagnostic_context *dc);
352+
diagnostic_context *dc,
353+
void (*target_option_override_hook) (void));
348354
extern int option_enabled (int opt_idx, void *opts);
349355
extern bool get_option_state (struct gcc_options *, int,
350356
struct cl_option_state *);
@@ -391,14 +397,16 @@ extern bool common_handle_option (struct gcc_options *opts,
391397
unsigned int lang_mask, int kind,
392398
location_t loc,
393399
const struct cl_option_handlers *handlers,
394-
diagnostic_context *dc);
400+
diagnostic_context *dc,
401+
void (*target_option_override_hook) (void));
395402
extern bool target_handle_option (struct gcc_options *opts,
396403
struct gcc_options *opts_set,
397404
const struct cl_decoded_option *decoded,
398405
unsigned int lang_mask, int kind,
399406
location_t loc,
400407
const struct cl_option_handlers *handlers,
401-
diagnostic_context *dc);
408+
diagnostic_context *dc,
409+
void (*target_option_override_hook) (void));
402410
extern void finish_options (struct gcc_options *opts,
403411
struct gcc_options *opts_set,
404412
location_t loc);

gcc/toplev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2149,7 +2149,8 @@ toplev::main (int argc, char **argv)
21492149
enough to default flags appropriately. */
21502150
decode_options (&global_options, &global_options_set,
21512151
save_decoded_options, save_decoded_options_count,
2152-
UNKNOWN_LOCATION, global_dc);
2152+
UNKNOWN_LOCATION, global_dc,
2153+
targetm.target_option.override);
21532154

21542155
handle_common_deferred_options ();
21552156

0 commit comments

Comments
 (0)