From 6b00b2bff991f3035450f1c759eb9261346562c1 Mon Sep 17 00:00:00 2001 From: Yaossg Date: Mon, 14 Apr 2025 19:52:51 +0800 Subject: [PATCH] fix continue in do-while --- boot.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/boot.c b/boot.c index 1a67fac..ff6b4ee 100644 --- a/boot.c +++ b/boot.c @@ -1697,15 +1697,17 @@ void parse_for() { } void parse_do_while() { + int body_label = next_label(); int cont_label = next_label(); int break_label = next_label(); asm_push_label(break_label, cont_label); - asm_label(cont_label); + asm_label(body_label); parse_stmt(); // body expect_token(TOKEN_WHILE); expect_token(TOKEN_PAREN_LEFT); + asm_label(cont_label); int cond = parse_expr(); - asm_bnez(cond, cont_label); + asm_bnez(cond, body_label); expect_token(TOKEN_PAREN_RIGHT); asm_label(break_label); asm_pop_label();