File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed
cpp/autosar/test/rules/A7-1-2 Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change 8
8
| test.cpp:44:16:44:17 | lc | Variable 'lc' could be marked 'constexpr'. |
9
9
| test.cpp:45:17:45:19 | lc2 | Variable 'lc2' could be marked 'constexpr'. |
10
10
| test.cpp:55:7:55:8 | m2 | Variable 'm2' could be marked 'constexpr' and static. |
11
+ | test.cpp:65:7:65:8 | x2 | Variable 'x2' could be marked 'constexpr'. |
12
+ | test.cpp:66:13:66:14 | x3 | Variable 'x3' could be marked 'constexpr'. |
11
13
| test.cpp:130:7:130:8 | m1 | Variable 'm1' could be marked 'constexpr' and static. |
12
14
| test.cpp:141:7:141:8 | m1 | Variable 'm1' could be marked 'constexpr' and static. |
13
15
| test.cpp:221:7:221:8 | l1 | Variable 'l1' could be marked 'constexpr'. |
Original file line number Diff line number Diff line change @@ -56,16 +56,16 @@ class MemberConstExpr {
56
56
int m3 = 0 ; // COMPLIANT - can be set by constructor
57
57
};
58
58
59
- int h1 (int x, int y) { // NON_COMPLIANT
60
- return x + y;
61
- }
59
+ int h1 (int x, int y) { return x + y; }
62
60
63
- constexpr int h1_correct (int x, int y) { // COMPLIANT
64
- return x + y;
65
- }
61
+ constexpr int h1_const (int x, int y) { return x + y; }
66
62
67
- int h2 (int x) { return h1 (x, 1 ) + 1 ; } // NON_COMPLIANT
68
- constexpr int h2_correct (int x) { return h1_correct (x, 1 ) + 1 ; } // COMPLIANT
63
+ int h2 () {
64
+ int x1 = h1 (1 , 1 ); // COMPLIANT
65
+ int x2 = h1_const (1 , 1 ); // NON_COMPLIANT
66
+ const int x3 = h1_const (1 , 1 ); // NON_COMPLIANT
67
+ constexpr int x4 = h1_const (1 , 1 ); // COMPLIANT
68
+ }
69
69
70
70
int h3 (int x) { // COMPLIANT - uses goto, so can't be constexpr
71
71
if (x) {
You can’t perform that action at this time.
0 commit comments