mirror of
https://github.com/github/codeql.git
synced 2026-05-03 20:58:03 +02:00
CPP: Add a test of AV Rule 186.ql.
This commit is contained in:
@@ -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. |
|
||||
@@ -0,0 +1 @@
|
||||
jsf/4.24 Control Flow Structures/AV Rule 186.ql
|
||||
@@ -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]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user