Gcc's online help (the output of gcc --help -v) includes a large number of undocumented options (197 in 5.1.0). For example, the section listing language-related options starts with the following and another 44 or so undocumented options:
The following options are language-related: --all-warnings This switch lacks documentation --ansi This switch lacks documentation --assert This switch lacks documentation ... It turns out that all of those in the section above and a good number of others are synonyms for other options that are in fact documented. Rather than duplicating the documentation for the alternate options, the small patchlet below modifies the print_filtered_help function to print the help for the documented alias along with its name. With it applied, the number of options that "lack documentation" drops to 114, and the section above looks like this: The following options are language-related: --all-warnings Enable most warning messages. Same as -Wall --ansi A synonym for -std=c89 (for C) or -std=c++98 (for C++). Same as -ansi -A<question>=<answer> Assert the <answer> to <question>. Putting '-' before <question> disables the <answer> to <question>. Same as -A -A<question>=<answer> Assert the <answer> to <question>. Putting '-' before <question> disables the <answer> to <question>. Same as -A 2015-10-14 Martin Sebor <mse...@redhat.com> * options.c (print_filtered_help): Print help for aliased option and its name instead of undocumented text for undocumented options. diff --git a/gcc/opts.c b/gcc/opts.c index 2bbf653..e441924 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -1010,7 +1010,7 @@ print_filtered_help (unsigned int include_flags, const char *help; bool found = false; bool displayed = false; - char new_help[128]; + char new_help[256]; if (include_flags == CL_PARAMS) { @@ -1086,6 +1086,23 @@ print_filtered_help (unsigned int include_flags, { if (exclude_flags & CL_UNDOCUMENTED) continue; + + if (option->alias_target < N_OPTS + && cl_options [option->alias_target].help) + { + /* For undocumented options that are aliases for other + options that are documented, print the other option's + help and name. */ + help = cl_options [option->alias_target].help; + + snprintf (new_help, sizeof new_help, "%s", help); + snprintf (new_help + strlen (new_help), + sizeof new_help - strlen (new_help), + ". Same as %s", + cl_options [option->alias_target].opt_text); + help = new_help; + } + else help = undocumented_msg; }