Skip to content

Commit 7ea6c1b

Browse files
committed
CPP: Add a test of AV Rule 186.ql.
1 parent f7dda1b commit 7ea6c1b

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| test.c:14:6:14:15 | not_called | AV Rule 186: There shall be no unreachable code. |
2+
| test.c:32:3:32:6 | ExprStmt | AV Rule 186: There shall be no unreachable code. |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
jsf/4.24 Control Flow Structures/AV Rule 186.ql
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
int x = 0;
3+
4+
void called1()
5+
{
6+
x++;
7+
}
8+
9+
void called2()
10+
{
11+
x++;
12+
}
13+
14+
void not_called()
15+
{
16+
x++; // BAD: unreachable
17+
}
18+
19+
int main(int argc, const char* argv[])
20+
{
21+
void (*fun_ptr)() = &called2;
22+
23+
called1();
24+
called2();
25+
26+
if (argc > 4)
27+
{
28+
x++;
29+
while (1) {
30+
x++;
31+
}
32+
x++; // BAD: unreachable
33+
} else if (argc > 4) {
34+
x++; // BAD: unreachable [NOT DETECTED]
35+
} else if (argc > 5) {
36+
x++; // BAD: unreachable [NOT DETECTED]
37+
}
38+
}

0 commit comments

Comments
 (0)