Skip to content

Commit fe630e9

Browse files
committed
Annotate test cases to explain their intent
1 parent 28f54a7 commit fe630e9

File tree

2 files changed

+40
-32
lines changed

2 files changed

+40
-32
lines changed

cpp/autosar/test/rules/A7-1-2/VariableMissingConstexpr.expected

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@
1010
| test.cpp:55:7:55:8 | m2 | Variable m2 could be marked 'constexpr'. |
1111
| test.cpp:130:7:130:8 | m1 | Variable m1 could be marked 'constexpr'. |
1212
| test.cpp:141:7:141:8 | m1 | Variable m1 could be marked 'constexpr'. |
13-
| test.cpp:217:7:217:7 | x | Variable x could be marked 'constexpr'. |
14-
| test.cpp:228:7:228:7 | v | Variable v could be marked 'constexpr'. |
15-
| test.cpp:229:7:229:7 | w | Variable w could be marked 'constexpr'. |
16-
| test.cpp:230:7:230:7 | a | Variable a could be marked 'constexpr'. |
17-
| test.cpp:231:7:231:7 | b | Variable b could be marked 'constexpr'. |
18-
| test.cpp:235:7:235:7 | f | Variable f could be marked 'constexpr'. |
19-
| test.cpp:236:7:236:7 | g | Variable g could be marked 'constexpr'. |
20-
| test.cpp:237:7:237:7 | h | Variable h could be marked 'constexpr'. |
21-
| test.cpp:238:7:238:7 | i | Variable i could be marked 'constexpr'. |
22-
| test.cpp:241:7:241:7 | l | Variable l could be marked 'constexpr'. |
23-
| test.cpp:244:7:244:7 | o | Variable o could be marked 'constexpr'. |
24-
| test.cpp:245:7:245:7 | q | Variable q could be marked 'constexpr'. |
13+
| test.cpp:221:7:221:7 | x | Variable x could be marked 'constexpr'. |
14+
| test.cpp:234:7:234:7 | v | Variable v could be marked 'constexpr'. |
15+
| test.cpp:235:7:235:7 | w | Variable w could be marked 'constexpr'. |
16+
| test.cpp:237:7:237:7 | a | Variable a could be marked 'constexpr'. |
17+
| test.cpp:239:7:239:7 | b | Variable b could be marked 'constexpr'. |
18+
| test.cpp:242:7:242:7 | e | Variable e could be marked 'constexpr'. |
19+
| test.cpp:244:7:244:7 | f | Variable f could be marked 'constexpr'. |
20+
| test.cpp:245:7:245:7 | g | Variable g could be marked 'constexpr'. |
21+
| test.cpp:248:7:248:7 | j | Variable j could be marked 'constexpr'. |
22+
| test.cpp:252:7:252:7 | m | Variable m could be marked 'constexpr'. |
23+
| test.cpp:253:7:253:7 | n | Variable n could be marked 'constexpr'. |

cpp/autosar/test/rules/A7-1-2/test.cpp

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,13 @@ class ExcludedCases {
208208

209209
extern int random();
210210
constexpr int add(int x, int y) { return x + y; }
211+
// Example with compile time constant literal value as default argument
211212
constexpr int add1(int x, int y = 1) { return x + y; }
213+
// Example with compile time constant function call as default argument
212214
constexpr int add2(int x, int y = add(add1(1), 2)) { return x + y; }
215+
// Example with non compile time constant function call as default argument
213216
constexpr int add3(int x, int y = random()) { return x + y; }
217+
// Example with compile time constant literal value as default arguments
214218
constexpr int add4(int x = 1, int y = 2) { return x + y; }
215219

216220
constexpr void fp_reported_in_466(int p) {
@@ -224,24 +228,29 @@ constexpr void fp_reported_in_466(int p) {
224228
z = p;
225229
}
226230

227-
int u = add(z, 2); // COMPLIANT
228-
int v = add(x, 2); // NON_COMPLIANT
229-
int w = add1(x, 2); // NON_COMPLIANT
230-
int a = add1(x); // NON_COMPLIANT
231-
int b = add1(1); // NON_COMPLIANT
232-
int c = add1(1, z); // COMPLIANT
233-
int d = add1(1, z); // COMPLIANT
234-
int e = add1(z); // COMPLIANT
235-
int f = add2(1); // NON_COMPLIANT
236-
int g = add2(1, 2); // NON_COMPLIANT
237-
int h = add2(x, 2); // NON_COMPLIANT
238-
int i = add2(x, 2); // NON_COMPLIANT
239-
int j = add2(z); // COMPLIANT
240-
int k = add2(z, 1); // COMPLIANT
241-
int l = add3(1, 1); // NON_COMPLIANT
242-
int m = add3(1); // COMPLIANT
243-
int n = add3(1, z); // COMPLIANT
244-
int o = add4(); // NON_COMPLIANT
245-
int q = add4(1); // NON_COMPLIANT
246-
int r = add4(1, z); // COMPLIANT
231+
constexpr int t = add(1, 2); // COMPLIANT
232+
233+
int u = add(z, 2); // COMPLIANT - z is not compile time constant on all paths
234+
int v = add(t, 2); // NON_COMPLIANT
235+
int w =
236+
add1(t, 2); // NON_COMPLIANT - all arguments are compile time constants
237+
int a = add1(t); // NON_COMPLIANT - s and the default value of the second
238+
// argument are compile time constants
239+
int b = add1(1); // NON_COMPLIANT
240+
int c = add1(1, z); // COMPLIANT - z is not compile time constant on all paths
241+
int d = add1(z); // COMPLIANT - z is not compile time constant on all paths
242+
int e = add2(1); // NON_COMPLIANT - provided argument and default value are
243+
// compile time constants
244+
int f = add2(1, 2); // NON_COMPLIANT
245+
int g = add2(t, 2); // NON_COMPLIANT
246+
int h = add2(z); // COMPLIANT - z is not compile time constant on all paths
247+
int i = add2(z, 1); // COMPLIANT - z is not compile time constant on all paths
248+
int j = add3(1, 1); // NON_COMPLIANT
249+
int k = add3(1); // COMPLIANT - default value for second argument is not a
250+
// compile time constant
251+
int l = add3(1, z); // COMPLIANT - z is not compile time constant on all paths
252+
int m = add4(); // NON_COMPLIANT - default values are compile time constants
253+
int n = add4(1); // NON_COMPLIANT - default value for second argument is a
254+
// compile time constant
255+
int o = add4(1, z); // COMPLIANT - z is not compile time constant on all paths
247256
}

0 commit comments

Comments
 (0)