Skip to content

Commit

Permalink
Merge pull request #91 from vacantron/bugfix
Browse files Browse the repository at this point in the history
Handle breaking out of do-while loop
  • Loading branch information
jserv authored Dec 12, 2023
2 parents c694400 + b45421e commit 5b54fd4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/cfront.c
Original file line number Diff line number Diff line change
Expand Up @@ -2899,8 +2899,15 @@ basic_block_t *read_body_statement(block_t *parent, basic_block_t *bb)
var_start->init_val = ph1_ir_idx - 1;
lex_expect(T_semicolon);

bb_connect(cond_, bb, THEN);
bb_connect(cond_, do_while_end, ELSE);
int i;
for (i = 0; i < MAX_BB_PRED; i++) {
if (cond_->prev[i].bb) {
bb_connect(cond_, bb, THEN);
bb_connect(cond_, do_while_end, ELSE);
break;
}
/* if breaking out of loop, skip condition block */
}

continue_pos_idx--;
break_exit_idx--;
Expand Down

0 comments on commit 5b54fd4

Please sign in to comment.