Skip to content

Commit 43cd9cd

Browse files
committed
Expand on test comment why the new test case is required
1 parent acffeca commit 43cd9cd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

clang/test/SemaCXX/warn-unused-private-field.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,20 @@ class SpaceShipDefaultCompare {
2121
};
2222

2323
class EqDefaultCompareOutOfClass {
24-
int used; // no warning
24+
int used; // no warning, the compiler generated AST for the comparison operator
25+
// references the fields of the class, and this should be considered
26+
// a use.
27+
// This test case is needed because clang does not emit the body
28+
// of the defaulted operator when it is defined in-class until it
29+
// finds a call to it. `-Wunused-private-field` is suppressed in
30+
// a different way in that case.
2531
bool operator==(const EqDefaultCompareOutOfClass &) const;
2632
};
2733

2834
bool EqDefaultCompareOutOfClass::operator==(const EqDefaultCompareOutOfClass &) const = default;
2935

3036
class FriendEqDefaultCompareOutOfClass {
31-
int used; // no warning
37+
int used; // no warning, same reasoning just tested via a friend declaration.
3238
friend bool operator==(const FriendEqDefaultCompareOutOfClass &, const FriendEqDefaultCompareOutOfClass &);
3339
};
3440

0 commit comments

Comments
 (0)