Skip to content

Commit

Permalink
Fix error with return statement in for-loop body
Browse files Browse the repository at this point in the history
This error occurred when a return statement was in for-loop body. After
parsing loop body, "body_" was assigned NULL as the return value,
causing the compiler to failed in correctly connect "inc_" and
"cond_start" basic blocks.

This error can be analyzed by examining the CFG.dot file.
  • Loading branch information
nosba0957 committed Aug 6, 2024
1 parent 13b828d commit c84d25e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2608,6 +2608,8 @@ basic_block_t *read_body_statement(block_t *parent, basic_block_t *bb)
if (body_) {
bb_connect(body_, inc_, NEXT);
bb_connect(inc_, cond_start, NEXT);
} else if (inc_->insn_list.head) {
bb_connect(inc_, cond_start, NEXT);
} else {
/* TODO: Release dangling inc basic block */
}
Expand Down

0 comments on commit c84d25e

Please sign in to comment.