On Sun, 2015-11-01 at 23:44 -0700, Jeff Law wrote: > On 10/30/2015 06:47 AM, David Malcolm wrote: > > > The typename suggestion seems to be at least somewhat controversial, > > whereas (I hope) the misspelled field names suggestion is more > > acceptable. > > > > Hence I'm focusing on the field name lookup for now; other uses of the > > algorithm (e.g. the typename lookup) could be done in followup patches, > > but I'm deferring them for now in the hope of getting the simplest case > > into trunk as a first step. Similarly, for simplicity, I didn't > > implement any attempt at error-recovery using the hint. > > > > The following patch kit is in two parts (for ease of review; they would > > be applied together): > > > > patch 1: Implement Levenshtein distance > > patch 2: C FE: suggest corrections for misspelled field names > > > > I didn't implement a limiter, on the grounds that this only fires > > once per "has no member named" error, and so is unlikely to slow > > things down noticeably. > > > > Successfully bootstrapped®rtested the combination of these two > > on x86_64-pc-linux-gnu (adds 11 new PASS results to gcc.sum) > > > > OK for trunk? > > > > gcc/Makefile.in | 1 + > > gcc/c/c-typeck.c | 70 +++++++++++- > > gcc/spellcheck.c | 136 +++++++++++++++++++++++ > > gcc/spellcheck.h | 32 ++++++ > > gcc/testsuite/gcc.dg/plugin/levenshtein-test-1.c | 9 ++ > > gcc/testsuite/gcc.dg/plugin/levenshtein_plugin.c | 64 +++++++++++ > > gcc/testsuite/gcc.dg/plugin/plugin.exp | 1 + > > gcc/testsuite/gcc.dg/spellcheck-fields.c | 63 +++++++++++ > > 8 files changed, 375 insertions(+), 1 deletion(-) > > create mode 100644 gcc/spellcheck.c > > create mode 100644 gcc/spellcheck.h > > create mode 100644 gcc/testsuite/gcc.dg/plugin/levenshtein-test-1.c > > create mode 100644 gcc/testsuite/gcc.dg/plugin/levenshtein_plugin.c > > create mode 100644 gcc/testsuite/gcc.dg/spellcheck-fields.c > I'm going to assume you got levenshtein's algorithm reasonably correct. > > This is OK for the trunk. Thanks. FWIW I applied some fixes for the nits identified by Mikael in: https://gcc.gnu.org/ml/gcc-patches/2015-11/msg00046.html renaming params "m" and "n" to "len_s" and "len_t", and fixing the comment - under the "obvious" rule. I've committed the combination of the two patches (with the nit fixes) as r230284; attached is what I committed (for reference). > Obviously I'd like to see it extend into the > other front-ends (C++ in particular). Then I'd like to see it extend > beyond just misspelled field names. (nods)