Skip to content

Commit 562ec5f

Browse files
committed
Fix error with return statement in for-loop body
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.
1 parent 4b8c4e6 commit 562ec5f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/parser.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2608,6 +2608,8 @@ basic_block_t *read_body_statement(block_t *parent, basic_block_t *bb)
26082608
if (body_) {
26092609
bb_connect(body_, inc_, NEXT);
26102610
bb_connect(inc_, cond_start, NEXT);
2611+
} else if (inc_->insn_list.head) {
2612+
bb_connect(inc_, cond_start, NEXT);
26112613
} else {
26122614
/* TODO: Release dangling inc basic block */
26132615
}

0 commit comments

Comments
 (0)