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

Ralf Wildenhues Ralf.Wildenhues@gmx.de
Thu Mar 5 21:20:00 GMT 2009


* Ralf Wildenhues wrote on Mon, Mar 02, 2009 at 09:51:33PM CET:
> > gcc.info documents:
> > 
> >             --help=warnings,^joined,^undocumented
> [...]
> 
> This patch is not good enough yet.  Will re-redo the opts.c part.

Next try.  When the user passes more than one of the qualifiers
  undocumented joined separate

but no classes, then the description sentence is taken from the first
matched one in that list that is used.  I think that should be good
enough.  It avoids the ICE from the PR, and with other combinations
of these qualifiers; see other patch introducing testsuite coverage.

OK for 4.4?  regtested i686-pc-linux-gnu.

Thanks,
Ralf

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

        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/opts.c b/gcc/opts.c
index 8ae79ae..7788b02 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -1515,6 +1515,8 @@ common_handle_option (size_t scode, const char *arg, int value,
 	      { "warnings", CL_WARNING },
 	      { "undocumented", CL_UNDOCUMENTED },
 	      { "params", CL_PARAMS },
+	      { "joined", CL_JOINED },
+	      { "separate", CL_SEPARATE },
 	      { "common", CL_COMMON },
 	      { NULL, 0 }
 	    };


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

        PR middle-end/37805
	* opts.c (print_specific_help): In addition to `undocumented',
	accept `separate' and `joined' flags if passed alone.  Describe
	output by the first matched one of those.
        (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.  One should not pass only
	negated qualifiers.  Fix markup and examples.

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 043cc98..14b2871 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,10 @@ 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
+The argument to @option{--help=} should not consist solely of inverted
+qualifiers.
+
+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 +1262,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 cf85618..ee95366 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 7788b02..6319770 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -1396,7 +1396,7 @@ print_specific_help (unsigned int include_flags,
 	default:
 	  if (i >= cl_lang_count)
 	    break;
-	  if ((exclude_flags & ((1U << cl_lang_count) - 1)) != 0)
+	  if (exclude_flags & all_langs_mask)
 	    description = _("The following options are specific to just the language ");
 	  else
 	    description = _("The following options are supported by the language ");
@@ -1409,8 +1409,12 @@ print_specific_help (unsigned int include_flags,
     {
       if (any_flags == 0)
 	{
-	  if (include_flags == CL_UNDOCUMENTED)
+	  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",
@@ -1539,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++)
@@ -1547,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