diff --git a/src/DU.h b/src/DU.h new file mode 100644 index 0000000..e69de29 diff --git a/src/globals.c b/src/globals.c index 553fb00..dca27e2 100644 --- a/src/globals.c +++ b/src/globals.c @@ -524,6 +524,8 @@ void bb_disconnect(basic_block_t *pred, basic_block_t *succ) /* The symbol is an argument of function or the variable in declaration */ void add_symbol(basic_block_t *bb, var_t *var) { + if (!bb) + return; symbol_t *sym; for (sym = bb->symbol_list.head; sym; sym = sym->next) { if (sym->var == var) diff --git a/tests/driver.sh b/tests/driver.sh index ec655c9..4859a29 100755 --- a/tests/driver.sh +++ b/tests/driver.sh @@ -271,6 +271,15 @@ int main() { } EOF +# Unreachable declaration should not cause prog seg-falut (prog should leave normally with exit code 0) +try_ 0 << EOF +int main() +{ + return 0; + int a = 5; +} +EOF + try_ 1 << EOF int is_odd(int x);