* RFA: Fix for PR 31349
@ 2008-02-18 13:20 Nick Clifton
2008-02-19 3:39 ` Mark Mitchell
0 siblings, 1 reply; 2+ messages in thread
From: Nick Clifton @ 2008-02-18 13:20 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 282 bytes --]
Hi Guys,
I would like to apply the attached patch to resolve PR 31349. It
updates the behaviour of the --help command line option so that it
is closer to the 4.2 behaviour, and it fixes a few minor issues with
the format of the --help output.
OK ?
Cheers
Nick
[-- Attachment #2: pr31349.patch --]
[-- Type: text/x-patch, Size: 6605 bytes --]
2008-01-23 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.
Index: gcc/opts.c
===================================================================
--- gcc/opts.c (revision 131757)
+++ gcc/opts.c (working copy)
@@ -337,7 +337,11 @@ bool no_unit_at_a_time_default;
struct visibility_flags visibility_options;
/* What to print when a switch has no documentation. */
+#ifdef ENABLE_CHECKING
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
-fprofile-use/-fprofile-generate does not use them. */
@@ -703,7 +707,7 @@ handle_options (unsigned int argc, const
{
if (main_input_filename == NULL)
{
- main_input_filename = opt;
+ main_input_filename = opt;
main_input_baselength
= base_of_path (main_input_filename, &main_input_basename);
}
@@ -1169,7 +1173,24 @@ print_filtered_help (unsigned int includ
}
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)
printf (_(" All options with the desired characteristics have already been displayed\n"));
@@ -1243,13 +1264,10 @@ print_specific_help (unsigned int includ
if (i >= cl_lang_count)
break;
if ((exclude_flags & ((1U << cl_lang_count) - 1)) != 0)
- {
- description = _("The following options are specific to the language ");
- descrip_extra = lang_names [i];
- }
+ description = _("The following options are specific to the just the language ");
else
description = _("The following options are supported by the language ");
- descrip_extra = lang_names [i];
+ descrip_extra = lang_names [i];
break;
}
}
@@ -1289,6 +1307,7 @@ static int
common_handle_option (size_t scode, const char *arg, int value,
unsigned int lang_mask)
{
+ static bool verbose = false;
enum opt_code code = (enum opt_code) scode;
switch (code)
@@ -1297,6 +1316,10 @@ common_handle_option (size_t scode, cons
handle_param (arg);
break;
+ case OPT_v:
+ verbose = true;
+ break;
+
case OPT_fhelp:
case OPT__help:
{
@@ -1304,7 +1327,7 @@ common_handle_option (size_t scode, cons
unsigned int undoc_mask;
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. */
for (i = 0; i < cl_lang_count; i++)
print_specific_help
@@ -1366,6 +1389,7 @@ common_handle_option (size_t scode, cons
};
unsigned int * pflags;
char * comma;
+ unsigned int lang_flag, specific_flag;
unsigned int len;
unsigned int i;
@@ -1383,28 +1407,52 @@ common_handle_option (size_t scode, cons
else
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)
{
- * 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;
}
- if (specifics[i].string == NULL)
+ if (specific_flag != 0)
{
- /* Check to see if the string matches a language name. */
- for (i = 0; i < cl_lang_count; i++)
- if (strncasecmp (a, lang_names[i], len) == 0)
- {
- * pflags |= 1U << i;
- break;
- }
-
- if (i == cl_lang_count)
- fnotice (stderr,
- "warning: unrecognized argument to --help= switch: %.*s\n",
- len, a);
+ if (lang_flag == 0)
+ * pflags |= specific_flag;
+ else
+ {
+ /* The option's argument matches both the start of a
+ 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
+ a warning. */
+ if (strncasecmp (a, "c", len) == 0)
+ * pflags |= lang_flag;
+ 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)
break;
Index: gcc/c.opt
===================================================================
--- gcc/c.opt (revision 131757)
+++ gcc/c.opt (working copy)
@@ -978,7 +978,7 @@ C ObjC C++ ObjC++
Do not predefine system-specific and GCC-specific macros
v
-C ObjC C++ ObjC++
+Common C ObjC C++ ObjC++
Enable verbose output
w
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: RFA: Fix for PR 31349
2008-02-18 13:20 RFA: Fix for PR 31349 Nick Clifton
@ 2008-02-19 3:39 ` Mark Mitchell
0 siblings, 0 replies; 2+ messages in thread
From: Mark Mitchell @ 2008-02-19 3:39 UTC (permalink / raw)
To: Nick Clifton; +Cc: gcc-patches
Nick Clifton wrote:
> Hi Guys,
>
> I would like to apply the attached patch to resolve PR 31349. It
> updates the behaviour of the --help command line option so that it
> is closer to the 4.2 behaviour, and it fixes a few minor issues with
> the format of the --help output.
>
> OK ?
OK.
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-02-19 3:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-18 13:20 RFA: Fix for PR 31349 Nick Clifton
2008-02-19 3:39 ` Mark Mitchell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).