aboutsummaryrefslogtreecommitdiff
path: root/stmt.c
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-05-16 12:57:50 -0700
committerMichael Forney <mforney@mforney.org>2019-05-16 12:59:04 -0700
commit52bf506762f2d04ba37701af41b7b06c0d6dc7f9 (patch)
tree08c2e3a25cb8bfa2eb8baee08902c9aba770a2ea /stmt.c
parent1b1092f3246eed96c796b1f74f814cb594be8768 (diff)
stmt: continue in do-loop should evaluate controlling expression
Diffstat (limited to 'stmt.c')
-rw-r--r--stmt.c12
1 files changed, 7 insertions, 5 deletions
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;