This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 2/2] C++ FE: handle misspelled identifiers and typenames
- From: David Malcolm <dmalcolm at redhat dot com>
- To: Jeff Law <law at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Thu, 14 Jul 2016 14:31:41 -0400
- Subject: Re: [PATCH 2/2] C++ FE: handle misspelled identifiers and typenames
- Authentication-results: sourceware.org; auth=none
- References: <1467312830-36082-1-git-send-email-dmalcolm@redhat.com> <1467312830-36082-2-git-send-email-dmalcolm@redhat.com> <6502df71-c1ed-8922-e054-a75cc0770fbf@redhat.com>
On Wed, 2016-07-13 at 16:12 -0600, Jeff Law wrote:
> On 06/30/2016 12:53 PM, David Malcolm wrote:
> > This is a port of the C frontend's r237714 [1] to the C++ frontend:
> > https://gcc.gnu.org/ml/gcc-patches/2016-06/msg01052.html
> > offering spelling suggestions for misspelled identifiers, macro
> > names,
> > and some keywords (e.g. "singed" vs "signed" aka PR c/70339).
> >
> > Unlike the C frontend, there doesn't seem to be an easy way to
> > distinguish between cases where we're expecting a typename vs
> > a variable name, so some of the logic is a little different.
> >
> > Examples of suggestions can be seen in the test case.
> >
> > Successfully bootstrapped®rtested on x86_64-pc-linux-gnu
> > (in combination with the prior patch); adds 240 PASS results to
> > g++.sum.
> >
> > OK for trunk?
> >
> > Dave
> >
> > [1] aka 8469aece13814deddf2cd80538d33c2d0a8d60d9 in the git mirror
> >
> > gcc/c/ChangeLog:
> > PR c/70339
> > * c-decl.c (struct edit_distance_traits<cpp_hashnode *>): Move
> > to
> > spellcheck-tree.h
> > (best_macro_match): Likewise, converting from a typedef to a
> > subclass.
> > (find_closest_macro_cpp_cb): Move to spellcheck-tree.c.
> > (lookup_name_fuzzy): Update for change of best_macro_match to a
> > subclass with a ctor that calls cpp_forall_identifiers.
> These are fine.
>
> >
> > gcc/cp/ChangeLog:
> > PR c/70339
> > * 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.
> > (consider_binding_levels): 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): Don't
> > attempt to access TYPE_FIELDS within a TYPE_PACK_EXPANSION.
> Going to let Jason on this part.
Thanks. The corresponding code in the C frontend is likely to change
due to the fix being discussed for PR c/71858, so I think I'll wait
until that other PR is fixed, and then resubmit an updated version of
this for review, incorporating equivalent fixes for C++.
> >
> > gcc/ChangeLog:
> > PR c/70339
> > * diagnostic-show-locus.c (diagnostic_show_locus): If this is
> > the
> > same location as last time, don't skip if we have fix-it hints.
> > Clarify the skipping logic by converting it from one "if"
> > clause
> > to repeated "if" clauses.
> > * spellcheck-tree.c: Include "cpplib.h".
> > (find_closest_macro_cpp_cb): Move here from c/c-decl.c.
> > (best_macro_match::best_macro_match): New constructor.
> > * spellcheck-tree.h (struct edit_distance_traits<cpp_hashnode
> > *>):
> > Move here from c/c-decl.c.
> > (class best_macro_match): Move here from c/c-decl.c, converting
> > from a typedef to a subclass, gaining a ctor.
> OK.
>
> >
> > gcc/testsuite/ChangeLog:
> > PR c/70339
> > * g++.dg/spellcheck-identifiers.C: New test case, based on
> > gcc.dg/spellcheck-identifiers.c.
> > * g++.dg/spellcheck-typenames.C: New test case, based on
> > gcc.dg/spellcheck-typenames.c
> OK
>
>
> jeff
>