Skip to content

Commit 6261f31

Browse files
authored
Merge pull request #154 from fennecJ/skip_symbol_insertion_in_unreachable_BB
Skip symbol insertion for unreachable basic blocks
2 parents 3573b9f + 1a11b2a commit 6261f31

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/globals.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,8 @@ void bb_disconnect(basic_block_t *pred, basic_block_t *succ)
524524
/* The symbol is an argument of function or the variable in declaration */
525525
void add_symbol(basic_block_t *bb, var_t *var)
526526
{
527+
if (!bb)
528+
return;
527529
symbol_t *sym;
528530
for (sym = bb->symbol_list.head; sym; sym = sym->next) {
529531
if (sym->var == var)

tests/driver.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,15 @@ int main() {
271271
}
272272
EOF
273273

274+
# Unreachable declaration should not cause prog seg-falut (prog should leave normally with exit code 0)
275+
try_ 0 << EOF
276+
int main()
277+
{
278+
return 0;
279+
int a = 5;
280+
}
281+
EOF
282+
274283
try_ 1 << EOF
275284
int is_odd(int x);
276285

0 commit comments

Comments
 (0)