PR c++/62314: C++: add fixit hint to misspelled member names
commitaa3d115507245952eeda92ba12fb9e2b45d8177d
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 2 May 2016 19:09:30 +0000 (2 19:09 +0000)
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 2 May 2016 19:09:30 +0000 (2 19:09 +0000)
tree026c49c2d8eadd08c56f75e225d4cb516a351820
parent6df343635b95f61b0ca0fcfcb27d69613e5727d1
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235785 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/spellcheck-fields-2.C [new file with mode: 0644]