Skip to content

Commit

Permalink
Add cases in dead code test where the arrays are constexpr.
Browse files Browse the repository at this point in the history
Complemeting previous case where the integers used for the sizes of the
arrays were constexpr.
  • Loading branch information
fjatWbyT committed Sep 16, 2024
1 parent 15801d9 commit 468eabd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions cpp/common/test/rules/deadcode/DeadCode.expected
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
| test.cpp:79:17:80:3 | { ... } | This statement is dead code. |
| test.cpp:85:3:85:44 | declaration | This statement is dead code. |
| test.cpp:87:3:87:30 | declaration | This statement is dead code. |
| test.cpp:90:3:90:50 | declaration | This statement is dead code. |
7 changes: 5 additions & 2 deletions cpp/common/test/rules/deadcode/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,8 @@ int test_dead_code(int x) {

constexpr int unused_int{2}; // NON_COMPLIANT

return live5 + live6; // COMPLIANT
}
constexpr int constexpr_used_array[]{3, 4, 5}; // COMPLIANT
constexpr int constexpr_unused_array[]{0, 1, 2}; // NON_COMPLIANT

return live5 + live6 + constexpr_used_array[1]; // COMPLIANT
}

0 comments on commit 468eabd

Please sign in to comment.