[Bug c++/87409] Implement -Wunused-private-field
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Sep 24 11:20:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87409
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2018-09-24
Ever confirmed|0 |1
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Yes, it can only warn when there are no member functions that aren't defined in
the current TU. Even then, it might need additional work to check at the end of
a TU if there are non-inline function definitions:
struct A {
A();
void f();
private:
int i = 0;
};
A::A() { }
void A::f() { }
Here we'd need to do the check at the end of the TU, after everything has been
defined. Clang does warn for this example.
Clang suppresses the warning if the member declaration has attribute unused,
which we would need to do too.
More information about the Gcc-bugs
mailing list