[clang] [Clang] Fix -Wunused-private-field false negative with defaulted comparison operators (PR #116871)
Mészáros Gergely via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 20 02:48:21 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}}
+};
----------------
Maetveis wrote:
Its not relevant that the field is const, and the constructor is also irrelevant to the bug in question.
```suggestion
class HasUnusedField {
int unused_; // expected-warning{{private field 'unused_' is not used}}
};
```
https://github.com/llvm/llvm-project/pull/116871
More information about the cfe-commits
mailing list