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

--- Comment #7 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Author: dmalcolm
Date: Mon May  2 19:09:30 2016
New Revision: 235785

URL: https://gcc.gnu.org/viewcvs?rev=235785&root=gcc&view=rev
Log:
PR c++/62314: C++: add fixit hint to misspelled member names

When we emit a hint about a misspelled member name, it will slightly
aid readability if we use a fixit-hint to show the proposed
name in context within the source code (and in the future this
might support some kind of auto-apply in an IDE).

This patch adds such a hint to the C++ frontend, taking us from:

test.cc:10:15: error: 'struct foo' has no member named 'colour'; did you mean
'color'?
   return ptr->colour;
               ^~~~~~

to:

test.cc:10:15: error: 'struct foo' has no member named 'colour'; did you mean
'color'?
   return ptr->colour;
               ^~~~~~
               color

gcc/cp/ChangeLog:
        PR c++/62314
        * typeck.c (finish_class_member_access_expr): When
        giving a hint about a possibly-misspelled member name,
        add a fix-it replacement hint.

gcc/testsuite/ChangeLog:
        PR c++/62314
        * g++.dg/spellcheck-fields-2.C: New test case.


Added:
    trunk/gcc/testsuite/g++.dg/spellcheck-fields-2.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/typeck.c
    trunk/gcc/testsuite/ChangeLog

Reply via email to