On 04/24/2017 04:06 PM, David Malcolm wrote:
test.cc:12:13: note: field ‘int foo::m_field’ can be accessed via ‘int
foo::get_field() const’
return f->m_field;
^~~~~~~
get_field()
Assuming that an IDE can offer to apply fix-it hints, this should
make it easier to handle refactorings where one makes a field
private and adds a getter.
It also helps by letting the user know that a getter exists, and
the name of the getter ("is it "field", "get_field", etc?").
Neat!
OK for trunk?
gcc/cp/ChangeLog:
* call.c (maybe_suggest_accessor): New function.
(enforce_access): Call maybe_suggest_accessor for inaccessible
decls.
* cp-tree.h (locate_field_accessor): New decl.
* search.c (matches_code_and_type_p): New function.
(field_access_p): New function.
(direct_accessor_p): New function.
(reference_accessor_p): New function.
(field_accessor_p): New function.
(dfs_locate_field_accessor_pre): New function.
(locate_field_accessor): New function.
ok.
--
Nathan Sidwell