The warning is reported by clang, can help to remove an unused code.
Example: private field 'm_next' is not used: -Wunused-private-field
Note removal of private fields can change the ABI of a structure so this warning should never be turned on by -Wextra or -Wall.
Also I don't see how this warning can be implemented without seeing all functions and implementation of functions for a class which dont need to be in a header.
Sure, has limitations, but it was able to catch some dead code in GCC source files.
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.
Dup of bug 72789 *** This bug has been marked as a duplicate of bug 72789 ***