@@ -17,6 +17,9 @@ struct C {
17
17
int m;
18
18
};
19
19
20
+ void sample1 (int x){};
21
+ void sample2 (int y){};
22
+
20
23
int test_useless_assignment (int &x, int p) {
21
24
x = 0 ; // COMPLIANT - x is a reference parameter, so is visible by the caller
22
25
int y = 0 ; // NON_COMPLIANT - never used
@@ -49,7 +52,7 @@ int test_useless_assignment(int &x, int p) {
49
52
A *a3 = new A; // NON_COMPLIANT - POD class, no constructor/destructor
50
53
A *a4 = new A (); // NON_COMPLIANT - POD class, no constructor/destructor
51
54
A *a5 = nullptr ; // NON_COMPLIANT - null never read
52
- A a6{}; // COMPLIANT - `m ` assigned below
55
+ A a6{}; // COMPLIANT - `f ` assigned below
53
56
a6.f = 2 ; // COMPLIANT - we don't track the fields here, but we do track `a6`,
54
57
// so we'd consider this used by the assignment below
55
58
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) {
69
72
C *c4 = new C (); // COMPLIANT - this will call a constructor??
70
73
C *c5 = nullptr ; // NON_COMPLIANT - null never read
71
74
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
+
72
82
return y;
73
83
}
84
+
85
+ int main () { return 0 ; }
0 commit comments