Skip to content

Commit d6e30cd

Browse files
committed
C++: Add test showing unreachable instructions give spurious blocks in IRGuards
1 parent ff8b796 commit d6e30cd

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

cpp/ql/test/library-tests/controlflow/guards-ir/test.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,13 @@ int ternary_test(const char *path, int mode)
174174
{
175175
return (foo(path, mode) == 0 ? 1 : 0);
176176
}
177+
178+
void abort(void);
179+
180+
int abort_test(int x) {
181+
if (x) {
182+
x += 1;
183+
} else {
184+
abort();
185+
}
186+
}

cpp/ql/test/library-tests/controlflow/guards-ir/tests.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ astGuards
3535
| test.c:162:9:162:18 | ... < ... |
3636
| test.c:165:9:165:18 | ... < ... |
3737
| test.c:175:13:175:32 | ... == ... |
38+
| test.c:181:9:181:9 | x |
3839
| test.cpp:18:8:18:10 | call to get |
3940
| test.cpp:31:7:31:13 | ... == ... |
4041
| test.cpp:42:13:42:20 | call to getABool |
@@ -255,6 +256,10 @@ astGuardsControl
255256
| test.c:165:9:165:18 | ... < ... | true | 165 | 166 |
256257
| test.c:175:13:175:32 | ... == ... | false | 175 | 175 |
257258
| test.c:175:13:175:32 | ... == ... | true | 175 | 175 |
259+
| test.c:181:9:181:9 | x | false | 183 | 184 |
260+
| test.c:181:9:181:9 | x | false | 186 | 180 |
261+
| test.c:181:9:181:9 | x | true | 181 | 182 |
262+
| test.c:181:9:181:9 | x | true | 186 | 180 |
258263
| test.cpp:18:8:18:10 | call to get | true | 19 | 19 |
259264
| test.cpp:31:7:31:13 | ... == ... | false | 30 | 30 |
260265
| test.cpp:31:7:31:13 | ... == ... | false | 34 | 34 |
@@ -470,6 +475,7 @@ irGuards
470475
| test.c:162:9:162:18 | CompareLT: ... < ... |
471476
| test.c:165:9:165:18 | CompareLT: ... < ... |
472477
| test.c:175:13:175:32 | CompareEQ: ... == ... |
478+
| test.c:181:9:181:9 | Load: x |
473479
| test.cpp:18:8:18:12 | CompareNE: (bool)... |
474480
| test.cpp:31:7:31:13 | CompareEQ: ... == ... |
475481
| test.cpp:42:13:42:20 | Call: call to getABool |
@@ -667,6 +673,8 @@ irGuardsControl
667673
| test.c:165:9:165:18 | CompareLT: ... < ... | true | 165 | 166 |
668674
| test.c:175:13:175:32 | CompareEQ: ... == ... | false | 175 | 175 |
669675
| test.c:175:13:175:32 | CompareEQ: ... == ... | true | 175 | 175 |
676+
| test.c:181:9:181:9 | Load: x | false | 184 | 184 |
677+
| test.c:181:9:181:9 | Load: x | true | 182 | 182 |
670678
| test.cpp:18:8:18:12 | CompareNE: (bool)... | true | 19 | 19 |
671679
| test.cpp:31:7:31:13 | CompareEQ: ... == ... | false | 34 | 34 |
672680
| test.cpp:31:7:31:13 | CompareEQ: ... == ... | true | 30 | 30 |

0 commit comments

Comments
 (0)