Skip to content

Commit 468eabd

Browse files
committed
Add cases in dead code test where the arrays are constexpr.
Complemeting previous case where the integers used for the sizes of the arrays were constexpr.
1 parent 15801d9 commit 468eabd

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

cpp/common/test/rules/deadcode/DeadCode.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
| test.cpp:79:17:80:3 | { ... } | This statement is dead code. |
1515
| test.cpp:85:3:85:44 | declaration | This statement is dead code. |
1616
| test.cpp:87:3:87:30 | declaration | This statement is dead code. |
17+
| test.cpp:90:3:90:50 | declaration | This statement is dead code. |

cpp/common/test/rules/deadcode/test.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,8 @@ int test_dead_code(int x) {
8686

8787
constexpr int unused_int{2}; // NON_COMPLIANT
8888

89-
return live5 + live6; // COMPLIANT
90-
}
89+
constexpr int constexpr_used_array[]{3, 4, 5}; // COMPLIANT
90+
constexpr int constexpr_unused_array[]{0, 1, 2}; // NON_COMPLIANT
91+
92+
return live5 + live6 + constexpr_used_array[1]; // COMPLIANT
93+
}

0 commit comments

Comments
 (0)