[RFC,5/7] Fix unhelpful messages for disabled options.
Commit Message
Firstly, the option handling was building suggestions without checking
if an option is disabled. This could have caused other unhelpful
messages for other mistyped options.
Secondly, the key issue here appears to be the lack of CL_JOINED flag
for the false 'Condition' i.e. an option is disabled but other flags are
zeroed out too. This caused find_opt() not to return the right index
to an option e.g. for -mabi= we would expect OPT_mabi_ rather than
OPT_SPECIAL_unknown, hence, the option did not appear to be correctly
marked as disabled. The patch aims to retain the extra flag but to keep
an option as disabled. I do not see any fallout with this, -m<opt>=
are now rejected on the command line and not printed with --target-help.
gcc/ChangeLog:
* opt-suggestions.c (option_proposer::build_option_suggestions):
Ignore disabled options.
* opts.c (print_filtered_help): Likewise.
* optc-gen.awk: Preserve flags in both cases.
gcc/testsuite/ChangeLog:
* gcc.target/nanomips/nanomips-err-mabi32.c: New test.
---
gcc/opt-suggestions.c | 3 +++
gcc/optc-gen.awk | 5 +++--
gcc/opts.c | 4 ++++
.../gcc.target/nanomips/nanomips-err-mabi32.c (new) | 4 ++++
4 files changed, 14 insertions(+), 2 deletions(-)
4 files changed, 14 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/nanomips/nanomips-err-mabi32.c
@@ -108,6 +108,9 @@ option_proposer::build_option_suggestions (const char *prefix)
switch (i)
{
default:
+ /* We don't want to suggest disabled options. */
+ if (option->cl_disabled)
+ continue;
if (option->var_type == CLVC_ENUM)
{
const struct cl_enum *e = &cl_enums[option->var_enum];
@@ -412,10 +412,11 @@ for (i = 0; i < n_opts; i++) {
" %s,\n" \
" 0, %s,\n" \
"#else\n" \
- " 0,\n" \
+ " %s,\n" \
" 1 /* Disabled. */, %s,\n" \
"#endif\n",
- condition, cl_flags, cl_bit_fields, cl_zero_bit_fields)
+ condition, cl_flags, cl_bit_fields,
+ cl_flags, cl_zero_bit_fields)
else
printf(" %s,\n" \
" 0, %s,\n",
@@ -1435,6 +1435,10 @@ print_filtered_help (unsigned int include_flags,
continue;
}
+ /* Skip disabled options. */
+ if (option->cl_disabled)
+ continue;
+
/* Skip unwanted switches. */
if ((option->flags & exclude_flags) != 0)
continue;
new file mode 100644
@@ -0,0 +1,4 @@
+/* Verify that we get an error for unsupported -mabi=32 option. */
+/* { dg-additional-options "-mabi=32" } */
+/* { dg-error "not supported by this configuration" "" { target *-*-* } 0 } */
+void foo (void) {}