Commit b3eaaf1a by Nick Clifton Committed by Nick Clifton

re PR other/31349 (gcc -v --help returns no options for C, C++)

        PR other/31349
        * opts.c (undocumented_msg): Leave blank unless checking is
        enabled.
        (handle_options): Fix indentation.
        (print_filtered_help): If no language-specific options were
        displayed tell the user how to list all the options supported by
        the language's front-end.
        (print_specific_help): Fix indentation and remove duplicate line.
        (common_handle_option): Handle the -v option.
        For --help enable the display of undocumented options if the -v
        switch has been included on the command line.
        For --help= check for overlaps in the arguments between the option
        classes and the language names and issue a warning when they
        cannot be disambiguated.
        * c.opt (v): Pass on to the common option handler.

From-SVN: r132427
parent d2ee546f
2008-02-19 Nick Clifton <nickc@redhat.com>
PR other/31349
* opts.c (undocumented_msg): Leave blank unless checking is
enabled.
(handle_options): Fix indentation.
(print_filtered_help): If no language-specific options were
displayed tell the user how to list all the options supported by
the language's front-end.
(print_specific_help): Fix indentation and remove duplicate line.
(common_handle_option): Handle the -v option.
For --help enable the display of undocumented options if the -v
switch has been included on the command line.
For --help= check for overlaps in the arguments between the option
classes and the language names and issue a warning when they
cannot be disambiguated.
* c.opt (v): Pass on to the common option handler.
2008-02-19 Revital Eres <eres@il.ibm.com> 2008-02-19 Revital Eres <eres@il.ibm.com>
* modulo-sched.c (sms_schedule): Change dump message when * modulo-sched.c (sms_schedule): Change dump message when
......
...@@ -978,7 +978,7 @@ C ObjC C++ ObjC++ ...@@ -978,7 +978,7 @@ C ObjC C++ ObjC++
Do not predefine system-specific and GCC-specific macros Do not predefine system-specific and GCC-specific macros
v v
C ObjC C++ ObjC++ Common C ObjC C++ ObjC++
Enable verbose output Enable verbose output
w w
......
...@@ -337,7 +337,11 @@ bool no_unit_at_a_time_default; ...@@ -337,7 +337,11 @@ bool no_unit_at_a_time_default;
struct visibility_flags visibility_options; struct visibility_flags visibility_options;
/* What to print when a switch has no documentation. */ /* What to print when a switch has no documentation. */
#ifdef ENABLE_CHECKING
static const char undocumented_msg[] = N_("This switch lacks documentation"); static const char undocumented_msg[] = N_("This switch lacks documentation");
#else
static const char undocumented_msg[] = "";
#endif
/* Used for bookkeeping on whether user set these flags so /* Used for bookkeeping on whether user set these flags so
-fprofile-use/-fprofile-generate does not use them. */ -fprofile-use/-fprofile-generate does not use them. */
...@@ -703,7 +707,7 @@ handle_options (unsigned int argc, const char **argv, unsigned int lang_mask) ...@@ -703,7 +707,7 @@ handle_options (unsigned int argc, const char **argv, unsigned int lang_mask)
{ {
if (main_input_filename == NULL) if (main_input_filename == NULL)
{ {
main_input_filename = opt; main_input_filename = opt;
main_input_baselength main_input_baselength
= base_of_path (main_input_filename, &main_input_basename); = base_of_path (main_input_filename, &main_input_basename);
} }
...@@ -1169,7 +1173,24 @@ print_filtered_help (unsigned int include_flags, ...@@ -1169,7 +1173,24 @@ print_filtered_help (unsigned int include_flags,
} }
if (! found) if (! found)
printf (_(" No options with the desired characteristics were found\n")); {
unsigned int langs = include_flags & CL_LANG_ALL;
if (langs == 0)
printf (_(" No options with the desired characteristics were found\n"));
else
{
unsigned int i;
/* PR 31349: Tell the user how to see all of the
options supported by a specific front end. */
for (i = 0; (1U << i) < CL_LANG_ALL; i ++)
if ((1U << i) & langs)
printf (_(" None found. Use --help=%s to show *all* the options supported by the %s front-end\n"),
lang_names[i], lang_names[i]);
}
}
else if (! displayed) else if (! displayed)
printf (_(" All options with the desired characteristics have already been displayed\n")); printf (_(" All options with the desired characteristics have already been displayed\n"));
...@@ -1243,13 +1264,10 @@ print_specific_help (unsigned int include_flags, ...@@ -1243,13 +1264,10 @@ print_specific_help (unsigned int include_flags,
if (i >= cl_lang_count) if (i >= cl_lang_count)
break; break;
if ((exclude_flags & ((1U << cl_lang_count) - 1)) != 0) if ((exclude_flags & ((1U << cl_lang_count) - 1)) != 0)
{ description = _("The following options are specific to the just the language ");
description = _("The following options are specific to the language ");
descrip_extra = lang_names [i];
}
else else
description = _("The following options are supported by the language "); description = _("The following options are supported by the language ");
descrip_extra = lang_names [i]; descrip_extra = lang_names [i];
break; break;
} }
} }
...@@ -1289,6 +1307,7 @@ static int ...@@ -1289,6 +1307,7 @@ static int
common_handle_option (size_t scode, const char *arg, int value, common_handle_option (size_t scode, const char *arg, int value,
unsigned int lang_mask) unsigned int lang_mask)
{ {
static bool verbose = false;
enum opt_code code = (enum opt_code) scode; enum opt_code code = (enum opt_code) scode;
switch (code) switch (code)
...@@ -1297,6 +1316,10 @@ common_handle_option (size_t scode, const char *arg, int value, ...@@ -1297,6 +1316,10 @@ common_handle_option (size_t scode, const char *arg, int value,
handle_param (arg); handle_param (arg);
break; break;
case OPT_v:
verbose = true;
break;
case OPT_fhelp: case OPT_fhelp:
case OPT__help: case OPT__help:
{ {
...@@ -1304,7 +1327,7 @@ common_handle_option (size_t scode, const char *arg, int value, ...@@ -1304,7 +1327,7 @@ common_handle_option (size_t scode, const char *arg, int value,
unsigned int undoc_mask; unsigned int undoc_mask;
unsigned int i; unsigned int i;
undoc_mask = extra_warnings ? 0 : CL_UNDOCUMENTED; undoc_mask = (verbose | extra_warnings) ? 0 : CL_UNDOCUMENTED;
/* 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
...@@ -1366,6 +1389,7 @@ common_handle_option (size_t scode, const char *arg, int value, ...@@ -1366,6 +1389,7 @@ common_handle_option (size_t scode, const char *arg, int value,
}; };
unsigned int * pflags; unsigned int * pflags;
char * comma; char * comma;
unsigned int lang_flag, specific_flag;
unsigned int len; unsigned int len;
unsigned int i; unsigned int i;
...@@ -1383,28 +1407,52 @@ common_handle_option (size_t scode, const char *arg, int value, ...@@ -1383,28 +1407,52 @@ common_handle_option (size_t scode, const char *arg, int value,
else else
len = comma - a; len = comma - a;
for (i = 0; specifics[i].string != NULL; i++) /* Check to see if the string matches an option class name. */
for (i = 0, specific_flag = 0; specifics[i].string != NULL; i++)
if (strncasecmp (a, specifics[i].string, len) == 0) if (strncasecmp (a, specifics[i].string, len) == 0)
{ {
* pflags |= specifics[i].flag; specific_flag = specifics[i].flag;
break;
}
/* Check to see if the string matches a language name.
Note - we rely upon the alpha-sorted nature of the entries in
the lang_names array, specifically that shorter names appear
before their longer variants. (ie C before C++). That way
when we are attempting to match --help=c for example we will
match with C first and not C++. */
for (i = 0, lang_flag = 0; i < cl_lang_count; i++)
if (strncasecmp (a, lang_names[i], len) == 0)
{
lang_flag = 1U << i;
break; break;
} }
if (specifics[i].string == NULL) if (specific_flag != 0)
{ {
/* Check to see if the string matches a language name. */ if (lang_flag == 0)
for (i = 0; i < cl_lang_count; i++) * pflags |= specific_flag;
if (strncasecmp (a, lang_names[i], len) == 0) else
{ {
* pflags |= 1U << i; /* The option's argument matches both the start of a
break; language name and the start of an option class name.
} We have a special case for when the user has
specified "--help=c", but otherwise we have to issue
if (i == cl_lang_count) a warning. */
fnotice (stderr, if (strncasecmp (a, "c", len) == 0)
"warning: unrecognized argument to --help= switch: %.*s\n", * pflags |= lang_flag;
len, a); else
fnotice (stderr,
"warning: --help argument %.*s is ambiguous, please be more specific\n",
len, a);
}
} }
else if (lang_flag != 0)
* pflags |= lang_flag;
else
fnotice (stderr,
"warning: unrecognized argument to --help= option: %.*s\n",
len, a);
if (comma == NULL) if (comma == NULL)
break; break;
......
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