Skip to content

Commit

Permalink
Merge pull request #154 from fennecJ/skip_symbol_insertion_in_unreach…
Browse files Browse the repository at this point in the history
…able_BB

Skip symbol insertion for unreachable basic blocks
  • Loading branch information
jserv authored Sep 25, 2024
2 parents 3573b9f + 1a11b2a commit 6261f31
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions tests/driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6261f31

Please sign in to comment.