This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/80567] [8 Regression] bogus fixit hint for undeclared memset: else


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80567

--- Comment #7 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Author: dmalcolm
Date: Wed Feb  7 17:55:54 2018
New Revision: 257456

URL: https://gcc.gnu.org/viewcvs?rev=257456&root=gcc&view=rev
Log:
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".


Added:
    trunk/gcc/testsuite/g++.dg/spellcheck-reswords.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/name-lookup.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/spellcheck-stdlib.C

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]