This is the mail archive of the gcc-patches@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]

Re: [PATCH 2/2] C++ FE: handle misspelled identifiers and typenames


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&regrtested 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
> 


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