@@ -17,6 +17,9 @@ struct C {
1717 int m;
1818};
1919
20+ void sample1 (int x){};
21+ void sample2 (int y){};
22+
2023int test_useless_assignment (int &x, int p) {
2124 x = 0 ; // COMPLIANT - x is a reference parameter, so is visible by the caller
2225 int y = 0 ; // NON_COMPLIANT - never used
@@ -49,7 +52,7 @@ int test_useless_assignment(int &x, int p) {
4952 A *a3 = new A; // NON_COMPLIANT - POD class, no constructor/destructor
5053 A *a4 = new A (); // NON_COMPLIANT - POD class, no constructor/destructor
5154 A *a5 = nullptr ; // NON_COMPLIANT - null never read
52- A a6{}; // COMPLIANT - `m ` assigned below
55+ A a6{}; // COMPLIANT - `f ` assigned below
5356 a6.f = 2 ; // COMPLIANT - we don't track the fields here, but we do track `a6`,
5457 // so we'd consider this used by the assignment below
5558 a6.f = 1 ; // NON_COMPLIANT - assignment into `f`, but `a6` is not used
@@ -69,5 +72,14 @@ int test_useless_assignment(int &x, int p) {
6972 C *c4 = new C (); // COMPLIANT - this will call a constructor??
7073 C *c5 = nullptr ; // NON_COMPLIANT - null never read
7174
75+ A a7{1 , 2 }; // COMPLIANT - used in the `sample1` call below
76+ sample1 (a7.f + a7.f2 ); // COMPLIANT - object access is a valid use
77+
78+ A *a8; // COMPLIANT - value not given at declaration
79+ a8 = &a7;
80+ sample2 (a8->f ); // COMPLIANT - object access is a valid use
81+
7282 return y;
7383}
84+
85+ int main () { return 0 ; }
0 commit comments