[clang] [Clang] Fix -Wunused-private-field false negative with defaulted comparison operators (PR #116871)
Chris White via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 20 10:38:34 PST 2024
================
@@ -20,6 +20,17 @@ class SpaceShipDefaultCompare {
int operator<=>(const SpaceShipDefaultCompare &) const = default;
};
+class UnusedConstPrivateField {
+ public:
+ UnusedConstPrivateField() : unused_(0) {}
+ private:
+ const int unused_; // expected-warning{{private field 'unused_' is not used}}
+};
+
+class FriendEqDefaultCompare {
+ friend auto operator==(FriendEqDefaultCompare, FriendEqDefaultCompare) -> bool = default;
----------------
whiteio wrote:
I've updated the tests, hopefully I didn't misinterpret your comments. I added a non-friend method to the unrelated class and added a case where the comparison is defined as a friend function.
https://github.com/llvm/llvm-project/pull/116871
More information about the cfe-commits
mailing list