CPP: Add a test of AV Rule 186.ql.

This commit is contained in:
Geoffrey White
2019-01-24 18:11:26 +00:00
parent f7dda1b3a4
commit 7ea6c1bcbe
3 changed files with 41 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
| test.c:14:6:14:15 | not_called | AV Rule 186: There shall be no unreachable code. |
| test.c:32:3:32:6 | ExprStmt | AV Rule 186: There shall be no unreachable code. |

View File

@@ -0,0 +1 @@
jsf/4.24 Control Flow Structures/AV Rule 186.ql

View File

@@ -0,0 +1,38 @@
int x = 0;
void called1()
{
x++;
}
void called2()
{
x++;
}
void not_called()
{
x++; // BAD: unreachable
}
int main(int argc, const char* argv[])
{
void (*fun_ptr)() = &called2;
called1();
called2();
if (argc > 4)
{
x++;
while (1) {
x++;
}
x++; // BAD: unreachable
} else if (argc > 4) {
x++; // BAD: unreachable [NOT DETECTED]
} else if (argc > 5) {
x++; // BAD: unreachable [NOT DETECTED]
}
}