[PATCH] PR middle-end/37805: --help=...,joined,undocumented

Ralf Wildenhues Ralf.Wildenhues@gmx.de
Sun Mar 1 10:13:00 GMT 2009


gcc.info documents:

            --help=warnings,^joined,^undocumented

(and 'gcc --help' lists those, too), but joined and undocumented don't
work any more since the PR 37805 patch.  This patch reverts that patch
and redoes it.

It is not a minimal change in the sense that: a minimal patch could just
remove the corresponding documentation along with the non-working
feature.  But it is pretty minimal in terms of changed code.  The
documentation is cleaned up a bit, too.

This is a regression over 4.3, which supported the above options, but
of course also had the ICE-on-invalid-arguments documented in the PR.

The 'len == 0' hunk fixes another glitch in that
  --help=,
  --help=,joined

currently assumes the first word before the comma to be 'optimizers'.

This patch is currently still bootstrapping & regtesting on
i686-pc-linux-gnu; 'make info html pdf' was successful and looks ok.

Note that the "undocumented" qualifier is pretty useless at the
moment.  AFAICS fixing that is a larger chunk of work, though.

And yes, this code dearly needs testsuite exposure.

Thanks,
Ralf

gcc/ChangeLog:
2009-03-01  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>

	PR middle-end/37805
	* opts.c (print_specific_help): Accept `separate' and `joined'
	as separate flags.
	(common_handle_option): Skip over empty strings.
	* gcc.c (display_help): Fix help string for `--help='.
	* doc/invoke.texi (Option Summary, Overall Options): With
	`--help=', classes and qualifiers can both be repeated, but
	only the latter can be negated.  Fix markup and examples.

	Revert
	2008-10-14  Jakub Jelinek  <jakub@redhat.com>
	PR middle-end/37805
	* opts.c (common_handle_option): Don't ICE on -fhelp=joined
	and -fhelp=separate.

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 043cc98..97b41f4 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -163,7 +163,7 @@ in the following sections.
 @item Overall Options
 @xref{Overall Options,,Options Controlling the Kind of Output}.
 @gccoptlist{-c  -S  -E  -o @var{file}  -combine  -pipe  -pass-exit-codes  @gol
--x @var{language}  -v  -###  --help@r{[}=@var{class}@r{]}  --target-help  @gol
+-x @var{language}  -v  -###  --help@r{[}=@var{class}@r{[},@dots{}@r{]]}  --target-help  @gol
 --version -wrapper@@@var{file}}
 
 @item C Language Options
@@ -1158,11 +1158,10 @@ Print (on the standard output) a description of target-specific command
 line options for each tool.  For some targets extra target-specific
 information may also be printed.
 
-@item --help=@var{class}@r{[},@var{qualifier}@r{]}
+@item --help=@{@var{class}@r{|[}^@r{]}@var{qualifier}@}@r{[},@dots{}@r{]}
 Print (on the standard output) a description of the command line
-options understood by the compiler that fit into a specific class.
-The class can be one of @samp{optimizers}, @samp{warnings}, @samp{target},
-@samp{params}, or @var{language}:
+options understood by the compiler that fit into all specified classes
+and qualifiers.  These are the supported classes:
 
 @table @asis
 @item @samp{optimizers}
@@ -1192,9 +1191,7 @@ version of GCC.
 This will display the options that are common to all languages.
 @end table
 
-It is possible to further refine the output of the @option{--help=}
-option by adding a comma separated list of qualifiers after the
-class.  These can be any from the following list:
+These are the supported qualifiers:
 
 @table @asis
 @item @samp{undocumented}
@@ -1218,7 +1215,7 @@ switches supported by the compiler the following can be used:
 @end smallexample
 
 The sense of a qualifier can be inverted by prefixing it with the
-@var{^} character, so for example to display all binary warning
+@samp{^} character, so for example to display all binary warning
 options (i.e., ones that are either on or off and that do not take an
 argument), which have a description the following can be used:
 
@@ -1226,7 +1223,7 @@ argument), which have a description the following can be used:
 --help=warnings,^joined,^undocumented
 @end smallexample
 
-A class can also be used as a qualifier, although this usually
+Combining several classes is possible, although this usually
 restricts the output by so much that there is nothing to display.  One
 case where it does work however is when one of the classes is
 @var{target}.  So for example to display all the target-specific
@@ -1262,7 +1259,7 @@ options, so for example it is possible to find out which optimizations
 are enabled at @option{-O2} by using:
 
 @smallexample
--O2 --help=optimizers
+-Q -O2 --help=optimizers
 @end smallexample
 
 Alternatively you can discover which binary optimizations are enabled
diff --git a/gcc/gcc.c b/gcc/gcc.c
index c2850bf..3270372 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -3228,7 +3228,7 @@ display_help (void)
   fputs (_("  -pass-exit-codes         Exit with highest error code from a phase\n"), stdout);
   fputs (_("  --help                   Display this information\n"), stdout);
   fputs (_("  --target-help            Display target specific command line options\n"), stdout);
-  fputs (_("  --help={target|optimizers|warnings|undocumented|params}[,{[^]joined|[^]separate}]\n"), stdout);
+  fputs (_("  --help={target|optimizers|warnings|params|[^]{joined|separate|undocumented}}[,...]\n"), stdout);
   fputs (_("                           Display specific types of command line options\n"), stdout);
   if (! verbose_flag)
     fputs (_("  (Use '-v --help' to display command line options of sub-processes)\n"), stdout);
diff --git a/gcc/opts.c b/gcc/opts.c
index 8ae79ae..ff6f69c 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -1411,6 +1411,10 @@ print_specific_help (unsigned int include_flags,
 	{
 	  if (include_flags == CL_UNDOCUMENTED)
 	    description = _("The following options are not documented");
+	  else if (include_flags == CL_SEPARATE)
+	    description = _("The following options take separate arguments");
+	  else if (include_flags == CL_JOINED)
+	    description = _("The following options take joined arguments");
 	  else
 	    {
 	      internal_error ("unrecognized include_flags 0x%x passed to print_specific_help",
@@ -1514,6 +1518,8 @@ common_handle_option (size_t scode, const char *arg, int value,
 	      { "target", CL_TARGET },
 	      { "warnings", CL_WARNING },
 	      { "undocumented", CL_UNDOCUMENTED },
+	      { "joined", CL_JOINED },
+	      { "separate", CL_SEPARATE },
 	      { "params", CL_PARAMS },
 	      { "common", CL_COMMON },
 	      { NULL, 0 }
@@ -1537,6 +1543,11 @@ common_handle_option (size_t scode, const char *arg, int value,
 	      len = strlen (a);
 	    else
 	      len = comma - a;
+	    if (len == 0)
+	      {
+		a = comma + 1;
+		continue;
+	      }
 
 	    /* Check to see if the string matches an option class name.  */
 	    for (i = 0, specific_flag = 0; specifics[i].string != NULL; i++)
@@ -1545,7 +1556,7 @@ common_handle_option (size_t scode, const char *arg, int value,
 		  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



More information about the Gcc-patches mailing list