PR driver/69265 and 69453: improved suggestions for various misspelled options
commitda7d506649266e077fb495752d08c127c96e45cb
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 12 Feb 2016 17:39:27 +0000 (12 17:39 +0000)
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 12 Feb 2016 17:39:27 +0000 (12 17:39 +0000)
tree570dfb8c0732f310844f592f252d735a0da81372
parentfcce1b0b4dcb9e1f0d2a4ad36a7a2baca8a2218b
PR driver/69265 and 69453: improved suggestions for various misspelled options

gcc/ChangeLog:
PR driver/69265
PR driver/69453
* gcc.c (driver::driver): Initialize m_option_suggestions.
(driver::~driver): Clean up m_option_suggestions.
(suggest_option): Convert to...
(driver::suggest_option): ...this, and split out into
driver::build_option_suggestions and find_closest_string.
(driver::build_option_suggestions): New function, from
first half of suggest_option.  Special-case
OPT_fsanitize_ and OPT_fsanitize_recover_, making use of
the sanitizer_opts array.  For options of enum types, add the
various enum values to the candidate strings.
(driver::handle_unrecognized_options): Remove "const".
* gcc.h (driver::handle_unrecognized_options): Likewise.
(driver::build_option_suggestions): New decl.
(driver::suggest_option): New decl.
(driver::m_option_suggestions): New field.
* opts-common.c (add_misspelling_candidates): New function.
* opts.c (sanitizer_opts): Remove decl of struct sanitizer_opts_s
and make non-static.
* opts.h (sanitizer_opts): New array decl.
(add_misspelling_candidates): New function decl.
* spellcheck.c (find_closest_string): New function.
* spellcheck.h (find_closest_string): New function decl.

gcc/testsuite/ChangeLog:
PR driver/69265
PR driver/69453
* gcc.dg/spellcheck-options-3.c: New test case.
* gcc.dg/spellcheck-options-4.c: New test case.
* gcc.dg/spellcheck-options-5.c: New test case.
* gcc.dg/spellcheck-options-6.c: New test case.
* gcc.dg/spellcheck-options-7.c: New test case.
* gcc.dg/spellcheck-options-8.c: New test case.
* gcc.dg/spellcheck-options-9.c: New test case.
* gcc.dg/spellcheck-options-10.c: New test case.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233382 138bc75d-0d04-0410-961f-82ee72b054a4
17 files changed:
gcc/ChangeLog
gcc/gcc.c
gcc/gcc.h
gcc/opts-common.c
gcc/opts.c
gcc/opts.h
gcc/spellcheck.c
gcc/spellcheck.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/spellcheck-options-10.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/spellcheck-options-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/spellcheck-options-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/spellcheck-options-5.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/spellcheck-options-6.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/spellcheck-options-7.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/spellcheck-options-8.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/spellcheck-options-9.c [new file with mode: 0644]