PR c++/62314: C++: add fixit hint to misspelled member names
commitbc1aee87f6494a59eea3ffbbb0577ccd85cdc4a1
authorDavid Malcolm <dmalcolm@redhat.com>
Mon, 2 May 2016 19:09:30 +0000 (2 19:09 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Mon, 2 May 2016 19:09:30 +0000 (2 19:09 +0000)
tree026c49c2d8eadd08c56f75e225d4cb516a351820
parent7caed520694ee532199e889eba09a900ecce1866
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.

From-SVN: r235785
gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/spellcheck-fields-2.C [new file with mode: 0644]