C++ FE: handle misspelled identifiers and typenames
commit24acd4ab61623430964b2fde87dc508b5e0cdf89
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Jul 2016 18:42:11 +0000 (20 18:42 +0000)
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Jul 2016 18:42:11 +0000 (20 18:42 +0000)
treeb49c604effb64ec60ec0f92309badfd3781fc6c4
parent09d899d1c260e25cb598476d39877ecd5ea80e3b
C++ FE: handle misspelled identifiers and typenames

gcc/cp/ChangeLog:
PR c/70339
PR c/71858
* name-lookup.c: Include gcc-rich-location.h, spellcheck-tree.h,
and parser.h.
(suggest_alternatives_for): If no candidates are found, try
lookup_name_fuzzy and report if if finds a suggestion.
(consider_binding_level): New function.
(lookup_name_fuzzy) New function.
* parser.c: Include gcc-rich-location.h.
(cp_lexer_next_token_is_decl_specifier_keyword): Move most of
logic into...
(cp_keyword_starts_decl_specifier_p): ...this new function.
(cp_parser_diagnose_invalid_type_name): When issuing
"does not name a type" errors, attempt to make a suggestion using
lookup_name_fuzzy.
* parser.h (cp_keyword_starts_decl_specifier_p): New prototype.
* search.c (lookup_field_fuzzy_info::fuzzy_lookup_field): Reject
types that are not CLASS_TYPE_P, rather than rejecting individual
tree codes.

gcc/testsuite/ChangeLog:
PR c/70339
PR c/71858
* g++.dg/spellcheck-identifiers.C: New test case, based on
gcc.dg/spellcheck-identifiers.c.
* g++.dg/spellcheck-identifiers-2.C: New test case, based on
gcc.dg/spellcheck-identifiers-2.c.
* g++.dg/spellcheck-typenames.C: New test case, based on
gcc.dg/spellcheck-typenames.c

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@238538 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/cp/parser.c
gcc/cp/parser.h
gcc/cp/search.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/spellcheck-identifiers-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/spellcheck-identifiers.C [new file with mode: 0644]
gcc/testsuite/g++.dg/spellcheck-typenames.C [new file with mode: 0644]