Skip to content

Commit 5cb30b0

Browse files
committed
CPP: Add a test case.
1 parent 02f4695 commit 5cb30b0

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
| test.cpp:2:2:2:12 | goto ... | This statement makes $@ unreachable. | test.cpp:3:2:3:5 | ExprStmt | ExprStmt |
22
| test.cpp:9:3:9:8 | break; | This statement makes $@ unreachable. | test.cpp:10:3:10:6 | ExprStmt | ExprStmt |
33
| test.cpp:37:3:37:8 | break; | This statement makes $@ unreachable. | test.cpp:38:3:38:11 | return ... | return ... |
4+
| test.cpp:91:2:91:11 | goto ... | This statement makes $@ unreachable. | test.cpp:93:2:93:5 | ExprStmt | ExprStmt |

cpp/ql/test/query-tests/Critical/DeadCodeGoto/test.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,29 @@ void test7(int x, int cond) {
8181
}
8282
end:
8383
}
84+
85+
#define CONFIG_DEFINE
86+
87+
void test8() {
88+
int x = 0;
89+
90+
#ifdef CONFIG_DEFINE
91+
goto skip; // GOOD (the `x++` is still reachable in some configurations) [FALSE POSITIVE]
92+
#endif
93+
x++;
94+
95+
skip:
96+
}
97+
98+
void test9() {
99+
int x = 0;
100+
101+
#ifdef CONFIG_NOTDEFINED
102+
goto mid;
103+
#endif
104+
goto end; // GOOD (the `x++` is still reachable in some configurations)
105+
mid:
106+
x++;
107+
108+
end:
109+
}

0 commit comments

Comments
 (0)