Skip to content

Commit cbeb018

Browse files
committed
Add test cases to A0-1-1 useless assignment.
1 parent 6640145 commit cbeb018

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@
1212
| test.cpp:94:11:94:17 | new | Definition of $@ is unused. | test.cpp:94:6:94:7 | b4 | b4 |
1313
| test.cpp:95:11:95:17 | 0 | Definition of $@ is unused. | test.cpp:95:6:95:7 | b5 | b5 |
1414
| test.cpp:103:11:103:17 | 0 | Definition of $@ is unused. | test.cpp:103:6:103:7 | c5 | c5 |
15+
| test.cpp:132:43:132:45 | {...} | Definition of $@ is unused. | test.cpp:132:7:132:18 | unused_array | unused_array |
16+
| test.cpp:134:29:134:31 | 0 | Definition of $@ is unused. | test.cpp:134:17:134:26 | unused_int | unused_int |

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,16 @@ template <typename T> void test_range_based_for_loop_template() {
123123
// template
124124
elem;
125125
}
126-
}
126+
}
127+
128+
#include <cstdint>
129+
130+
std::int32_t test_constexpr_array_size() {
131+
constexpr int constexpr_array_size = 7; // COMPLIANT
132+
int unused_array[constexpr_array_size] = {}; // NON_COMPLIANT
133+
134+
constexpr int unused_int = {}; // NON_COMPLIANT
135+
136+
std::int32_t used_array[] = {-1, 0, 1}; // COMPLIANT
137+
return used_array[1];
138+
}

0 commit comments

Comments
 (0)