Skip to content

Commit 5c3ccd1

Browse files
committed
Add more cases for FP
1 parent 9dc1879 commit 5c3ccd1

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

cpp/autosar/test/rules/A0-1-1/test.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ struct C {
1717
int m;
1818
};
1919

20+
void sample1(int x){};
21+
void sample2(int y){};
22+
2023
int 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

Comments
 (0)