Commit 2dcfc872 by Martin Liska Committed by Martin Liska

Postpone print of --help=* option.

2019-05-02  Martin Liska  <mliska@suse.cz>

	* gcc.c (process_command): Add dummy file only
	if n_infiles == 0.
	* opts-global.c (decode_options): Pass lang_mask.
	* opts.c (print_help): New function.
	(finish_options): Print --help if help_option_argument
	is set.
	(common_handle_option): Factor out content of OPT__help_
	into print_help.
	* opts.h (finish_options): Add new argument.

From-SVN: r270788
parent 786e0e52
2019-05-02 Martin Liska <mliska@suse.cz>
* gcc.c (process_command): Add dummy file only
if n_infiles == 0.
* opts-global.c (decode_options): Pass lang_mask.
* opts.c (print_help): New function.
(finish_options): Print --help if help_option_argument
is set.
(common_handle_option): Factor out content of OPT__help_
into print_help.
* opts.h (finish_options): Add new argument.
2019-05-02 Martin Liska <mliska@suse.cz>
PR target/88809
* config/i386/i386.c (ix86_expand_strlen): Use strlen call.
With -minline-all-stringops use inline expansion using 4B loop.
......
......@@ -4751,10 +4751,9 @@ process_command (unsigned int decoded_options_count,
}
/* Ensure we only invoke each subprocess once. */
if (print_subprocess_help || print_help_list || print_version)
if (n_infiles == 0
&& (print_subprocess_help || print_help_list || print_version))
{
n_infiles = 0;
/* Create a dummy input file, so that we can pass
the help option on to the various sub-processes. */
add_infile ("help-dummy", "c");
......
......@@ -314,7 +314,7 @@ decode_options (struct gcc_options *opts, struct gcc_options *opts_set,
loc, lang_mask,
&handlers, dc);
finish_options (opts, opts_set, loc);
finish_options (opts, opts_set, loc, lang_mask);
}
/* Hold command-line options associated with stack limitation. */
......
......@@ -855,12 +855,18 @@ control_options_for_live_patching (struct gcc_options *opts,
}
}
/* --help option argument if set. */
const char *help_option_argument = NULL;
static void print_help (struct gcc_options *opts, unsigned int lang_mask);
/* After all options at LOC have been read into OPTS and OPTS_SET,
finalize settings of those options and diagnose incompatible
combinations. */
void
finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
location_t loc)
location_t loc, unsigned int lang_mask)
{
enum unwind_info_type ui_except;
......@@ -1224,6 +1230,10 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
opts->x_flag_live_patching,
loc);
}
/* Print --help=* if used. */
if (help_option_argument != NULL)
print_help (opts, lang_mask);
}
#define LEFT_COLUMN 27
......@@ -2054,74 +2064,12 @@ check_alignment_argument (location_t loc, const char *flag, const char *name)
parse_and_check_align_values (flag, name, align_result, true, loc);
}
/* 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
DECODED->value assigned to a variable, it happens automatically. */
/* Print help when OPT__help_ is set. */
bool
common_handle_option (struct gcc_options *opts,
struct gcc_options *opts_set,
const struct cl_decoded_option *decoded,
unsigned int lang_mask, int kind ATTRIBUTE_UNUSED,
location_t loc,
const struct cl_option_handlers *handlers,
diagnostic_context *dc,
void (*target_option_override_hook) (void))
static void
print_help (struct gcc_options *opts, unsigned int lang_mask)
{
size_t scode = decoded->opt_index;
const char *arg = decoded->arg;
HOST_WIDE_INT value = decoded->value;
enum opt_code code = (enum opt_code) scode;
gcc_assert (decoded->canonical_option_num_elements <= 2);
switch (code)
{
case OPT__param:
handle_param (opts, opts_set, loc, arg);
break;
case OPT__help:
{
unsigned int all_langs_mask = (1U << cl_lang_count) - 1;
unsigned int undoc_mask;
unsigned int i;
if (lang_mask == CL_DRIVER)
break;
undoc_mask = ((opts->x_verbose_flag | opts->x_extra_warnings)
? 0
: CL_UNDOCUMENTED);
target_option_override_hook ();
/* First display any single language specific options. */
for (i = 0; i < cl_lang_count; i++)
print_specific_help
(1U << i, (all_langs_mask & (~ (1U << i))) | undoc_mask, 0, opts,
lang_mask);
/* Next display any multi language specific options. */
print_specific_help (0, undoc_mask, all_langs_mask, opts, lang_mask);
/* Then display any remaining, non-language options. */
for (i = CL_MIN_OPTION_CLASS; i <= CL_MAX_OPTION_CLASS; i <<= 1)
if (i != CL_DRIVER)
print_specific_help (i, undoc_mask, 0, opts, lang_mask);
opts->x_exit_after_options = true;
break;
}
case OPT__target_help:
if (lang_mask == CL_DRIVER)
break;
target_option_override_hook ();
print_specific_help (CL_TARGET, CL_UNDOCUMENTED, 0, opts, lang_mask);
opts->x_exit_after_options = true;
break;
case OPT__help_:
{
const char *a = arg;
const char *a = help_option_argument;
unsigned int include_flags = 0;
/* Note - by default we include undocumented options when listing
specific classes. If you only want to see documented options
......@@ -2131,7 +2079,7 @@ common_handle_option (struct gcc_options *opts,
unsigned int exclude_flags = 0;
if (lang_mask == CL_DRIVER)
break;
return;
/* Walk along the argument string, parsing each word in turn.
The format is:
......@@ -2168,7 +2116,7 @@ common_handle_option (struct gcc_options *opts,
++a;
if (*a == '\0')
{
error_at (loc, "missing argument to %qs", "--help=^");
error ("missing argument to %qs", "--help=^");
break;
}
pflags = &exclude_flags;
......@@ -2222,7 +2170,7 @@ common_handle_option (struct gcc_options *opts,
if (strncasecmp (a, "c", len) == 0)
*pflags |= lang_flag;
else
warning_at (loc, 0,
warning (0,
"--help argument %q.*s is ambiguous, "
"please be more specific",
len, a);
......@@ -2231,7 +2179,7 @@ common_handle_option (struct gcc_options *opts,
else if (lang_flag != 0)
*pflags |= lang_flag;
else
warning_at (loc, 0,
warning (0,
"unrecognized argument to --help= option: %q.*s",
len, a);
......@@ -2241,11 +2189,78 @@ common_handle_option (struct gcc_options *opts,
}
if (include_flags)
print_specific_help (include_flags, exclude_flags, 0, opts,
lang_mask);
}
/* 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
DECODED->value assigned to a variable, it happens automatically. */
bool
common_handle_option (struct gcc_options *opts,
struct gcc_options *opts_set,
const struct cl_decoded_option *decoded,
unsigned int lang_mask, int kind ATTRIBUTE_UNUSED,
location_t loc,
const struct cl_option_handlers *handlers,
diagnostic_context *dc,
void (*target_option_override_hook) (void))
{
size_t scode = decoded->opt_index;
const char *arg = decoded->arg;
HOST_WIDE_INT value = decoded->value;
enum opt_code code = (enum opt_code) scode;
gcc_assert (decoded->canonical_option_num_elements <= 2);
switch (code)
{
case OPT__param:
handle_param (opts, opts_set, loc, arg);
break;
case OPT__help:
{
unsigned int all_langs_mask = (1U << cl_lang_count) - 1;
unsigned int undoc_mask;
unsigned int i;
if (lang_mask == CL_DRIVER)
break;
undoc_mask = ((opts->x_verbose_flag | opts->x_extra_warnings)
? 0
: CL_UNDOCUMENTED);
target_option_override_hook ();
print_specific_help (include_flags, exclude_flags, 0, opts,
/* First display any single language specific options. */
for (i = 0; i < cl_lang_count; i++)
print_specific_help
(1U << i, (all_langs_mask & (~ (1U << i))) | undoc_mask, 0, opts,
lang_mask);
/* Next display any multi language specific options. */
print_specific_help (0, undoc_mask, all_langs_mask, opts, lang_mask);
/* Then display any remaining, non-language options. */
for (i = CL_MIN_OPTION_CLASS; i <= CL_MAX_OPTION_CLASS; i <<= 1)
if (i != CL_DRIVER)
print_specific_help (i, undoc_mask, 0, opts, lang_mask);
opts->x_exit_after_options = true;
break;
}
case OPT__target_help:
if (lang_mask == CL_DRIVER)
break;
target_option_override_hook ();
print_specific_help (CL_TARGET, CL_UNDOCUMENTED, 0, opts, lang_mask);
opts->x_exit_after_options = true;
break;
case OPT__help_:
{
help_option_argument = arg;
opts->x_exit_after_options = true;
break;
}
......
......@@ -418,7 +418,8 @@ extern bool target_handle_option (struct gcc_options *opts,
void (*target_option_override_hook) (void));
extern void finish_options (struct gcc_options *opts,
struct gcc_options *opts_set,
location_t loc);
location_t loc,
unsigned int lang_mask);
extern void default_options_optimization (struct gcc_options *opts,
struct gcc_options *opts_set,
struct cl_decoded_option *decoded_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