diff options
author | Martin Liska <mliska@suse.cz> | 2020-03-19 11:58:53 +0100 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2020-05-05 16:02:06 +0200 |
commit | 48c041033ec07b22fda380daa208ab754ec52b68 (patch) | |
tree | accb3810832117317dad9679ee5fd6b65a40dcd1 /gcc/dumpfile.c | |
parent | d2148424165849ac9fe413b7a8d7cd198959bebf (diff) | |
download | gcc-48c041033ec07b22fda380daa208ab754ec52b68.zip gcc-48c041033ec07b22fda380daa208ab754ec52b68.tar.gz gcc-48c041033ec07b22fda380daa208ab754ec52b68.tar.bz2 |
Provide hint for misspelled -fdump-foo options.
gcc/ChangeLog:
2020-03-19 Martin Liska <mliska@suse.cz>
* dumpfile.c (dump_switch_p): Change return type
and print option suggestion.
* dumpfile.h: Change return type.
* opts-global.c (handle_common_deferred_options):
Move error into dump_switch_p function.
gcc/testsuite/ChangeLog:
2020-03-19 Martin Liska <mliska@suse.cz>
* gcc.dg/spellcheck-options-22.c: New test.
Diffstat (limited to 'gcc/dumpfile.c')
-rw-r--r-- | gcc/dumpfile.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/gcc/dumpfile.c b/gcc/dumpfile.c index e392ecf..5471878 100644 --- a/gcc/dumpfile.c +++ b/gcc/dumpfile.c @@ -39,6 +39,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-pass.h" /* for "current_pass". */ #include "optinfo-emit-json.h" #include "stringpool.h" /* for get_identifier. */ +#include "spellcheck.h" /* If non-NULL, return one past-the-end of the matching SUBPART of the WHOLE string. */ @@ -1874,7 +1875,7 @@ dump_switch_p_1 (const char *arg, struct dump_file_info *dfi, bool doglob) return 1; } -int +void gcc::dump_manager:: dump_switch_p (const char *arg) { @@ -1896,8 +1897,20 @@ dump_switch_p (const char *arg) for (i = 0; i < m_extra_dump_files_in_use; i++) any |= dump_switch_p_1 (arg, &m_extra_dump_files[i], true); - - return any; + if (!any) + { + auto_vec<const char *> candidates; + for (size_t i = TDI_none + 1; i != TDI_end; i++) + candidates.safe_push (dump_files[i].swtch); + for (size_t i = 0; i < m_extra_dump_files_in_use; i++) + candidates.safe_push (m_extra_dump_files[i].swtch); + const char *hint = find_closest_string (arg, &candidates); + if (hint) + error ("unrecognized command-line option %<-fdump-%s%>; " + "did you mean %<-fdump-%s%>?", arg, hint); + else + error ("unrecognized command-line option %<-fdump-%s%>", arg); + } } /* Parse ARG as a -fopt-info switch and store flags, optgroup_flags |