From 52bf506762f2d04ba37701af41b7b06c0d6dc7f9 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Thu, 16 May 2019 12:57:50 -0700 Subject: stmt: continue in do-loop should evaluate controlling expression --- stmt.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'stmt.c') diff --git a/stmt.c b/stmt.c index c53c969..8d45e3c 100644 --- a/stmt.c +++ b/stmt.c @@ -177,24 +177,26 @@ stmt(struct func *f, struct scope *s) next(); label[0] = mkblock("do_body"); - label[1] = mkblock("do_join"); + label[1] = mkblock("do_cond"); + label[2] = mkblock("do_join"); s = mkscope(s); s = mkscope(s); - s->continuelabel = label[0]; - s->breaklabel = label[1]; + s->continuelabel = label[1]; + s->breaklabel = label[2]; funclabel(f, label[0]); stmt(f, s); s = delscope(s); expect(TWHILE, "after 'do' statement"); expect(TLPAREN, "after 'while'"); + funclabel(f, label[1]); e = expr(s); expect(TRPAREN, "after expression"); v = funcexpr(f, e); - funcjnz(f, v, label[0], label[1]); // XXX: compare to 0 - funclabel(f, label[1]); + funcjnz(f, v, label[0], label[2]); // XXX: compare to 0 + funclabel(f, label[2]); s = delscope(s); expect(TSEMICOLON, "after 'do' statement"); break; -- cgit v1.2.3