diff options
author | Martin Liska <mliska@suse.cz> | 2019-04-30 15:50:24 +0200 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2019-04-30 13:50:24 +0000 |
commit | 5bcc5a3b28d56bff2c70e5f52ce25f2cd7ee055e (patch) | |
tree | b434cee79d7c973543f21d75b421d156dc9a3bf1 /gcc/opts.c | |
parent | 44bf4743079e18380ff7ef208299545675f05671 (diff) | |
download | gcc-5bcc5a3b28d56bff2c70e5f52ce25f2cd7ee055e.zip gcc-5bcc5a3b28d56bff2c70e5f52ce25f2cd7ee055e.tar.gz gcc-5bcc5a3b28d56bff2c70e5f52ce25f2cd7ee055e.tar.bz2 |
Add option suggestion for -Werror=foo and corresponding pragma.
2019-04-30 Martin Liska <mliska@suse.cz>
* opts.c (enable_warning_as_error): Provide hints
for unknown options.
2019-04-30 Martin Liska <mliska@suse.cz>
* c-pragma.c (handle_pragma_diagnostic): Provide hints
for unknown options.
2019-04-30 Martin Liska <mliska@suse.cz>
* gcc.dg/Werror-13.c: Add new tests for it.
* gcc.dg/pragma-diag-6.c: Likewise.
From-SVN: r270693
Diffstat (limited to 'gcc/opts.c')
-rw-r--r-- | gcc/opts.c | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -31,6 +31,7 @@ along with GCC; see the file COPYING3. If not see #include "insn-attr-common.h" #include "common/common-target.h" #include "spellcheck.h" +#include "opt-suggestions.h" static void set_Wstrict_aliasing (struct gcc_options *opts, int onoff); @@ -3088,10 +3089,20 @@ enable_warning_as_error (const char *arg, int value, unsigned int lang_mask, strcpy (new_option + 1, arg); option_index = find_opt (new_option, lang_mask); if (option_index == OPT_SPECIAL_unknown) - error_at (loc, "%<-Werror=%s%>: no option -%s", arg, new_option); + { + option_proposer op; + const char *hint = op.suggest_option (new_option); + if (hint) + error_at (loc, "%<-W%serror=%s%>: no option %<-%s%>;" + " did you mean %<-%s%>?", value ? "" : "no-", + arg, new_option, hint); + else + error_at (loc, "%<-W%serror=%s%>: no option %<-%s%>", + value ? "" : "no-", arg, new_option); + } else if (!(cl_options[option_index].flags & CL_WARNING)) - error_at (loc, "%<-Werror=%s%>: -%s is not an option that controls " - "warnings", arg, new_option); + error_at (loc, "%<-Werror=%s%>: %<-%s%> is not an option that " + "controls warnings", arg, new_option); else { const diagnostic_t kind = value ? DK_ERROR : DK_WARNING; |