diff options
author | David Malcolm <dmalcolm@redhat.com> | 2018-02-07 17:55:54 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2018-02-07 17:55:54 +0000 |
commit | 0d7d8e66e4f6bcdfc363db28a4a79c3fe6d89beb (patch) | |
tree | acf80cb00db639a9d1bb07ecfc76a71a183fe04a /libgo | |
parent | 085e82463714a665bc0236fb753dd5a216a0507e (diff) | |
download | gcc-0d7d8e66e4f6bcdfc363db28a4a79c3fe6d89beb.zip gcc-0d7d8e66e4f6bcdfc363db28a4a79c3fe6d89beb.tar.gz gcc-0d7d8e66e4f6bcdfc363db28a4a79c3fe6d89beb.tar.bz2 |
C++: avoid most reserved words as misspelling suggestions (PR c++/81610 and PR c++/80567)
lookup_name_fuzzy can offer some reserved words as suggestions for
misspelled words, helping with "singed"/"signed" typos.
PR c++/81610 and PR c++/80567 report problems where the C++ frontend
suggested "if", "for" and "else" as corrections for misspelled variable
names.
The root cause is that in r247233
("Fix spelling suggestions for reserved words (PR c++/80177)")
I loosened the conditions on these reserved words, adding this condition:
if (kind == FUZZY_LOOKUP_TYPENAME)
to the logic for rejecting words that don't start decl-specifiers, to
allow for "static_assert" to be offered.
This is too loose a condition: we don't want to suggest *any* reserved word
when we're in a context where we don't know we expect a typename.
For the kinds of error-recover situations where we're suggesting
spelling corrections we don't have much contextual information, so it
seems prudent to be stricter about which reserved words we offer
as spelling suggestions; I don't think it makes sense for us to
suggest e.g. "for".
This patch implements that by effectively reinstating the old logic,
but special-casing RID_STATIC_ASSERT, moving the logic to a new
subroutine (in case we want to allow for other special-cases).
I attempted to add suggestions for the various RID_*CAST, to cope
with e.g. "reinterptet_cast" (I can never type that correctly on the
first try), but the following '<' token confuses the error-recovery
enough that the suggestion code isn't triggered.
gcc/cp/ChangeLog:
PR c++/81610
PR c++/80567
* name-lookup.c (suggest_rid_p): New function.
(lookup_name_fuzzy): Replace enum-rid-filtering logic with call to
suggest_rid_p.
gcc/testsuite/ChangeLog:
PR c++/81610
PR c++/80567
* g++.dg/spellcheck-reswords.C: New test case.
* g++.dg/spellcheck-stdlib.C: Remove xfail from dg-bogus
suggestion of "if".
From-SVN: r257456
Diffstat (limited to 'libgo')
0 files changed, 0 insertions, 0 deletions