aboutsummaryrefslogtreecommitdiff
path: root/stmt.c
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-07-03 00:16:16 -0700
committerMichael Forney <mforney@mforney.org>2019-07-03 02:40:53 -0700
commitd875bf74986b87378f80d7be4cd08e8eb8e91c65 (patch)
tree605f5b0b3339a9f9c049d63cb796f2d44f48ef15 /stmt.c
parent94ff44d9f3df0ce081bd66c5ebebee660608342b (diff)
Convert controlling expression of loops to bool
Diffstat (limited to 'stmt.c')
-rw-r--r--stmt.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/stmt.c b/stmt.c
index f7dd0cd..cf5209d 100644
--- a/stmt.c
+++ b/stmt.c
@@ -153,7 +153,7 @@ stmt(struct func *f, struct scope *s)
next();
s = mkscope(s);
expect(TLPAREN, "after 'while'");
- e = expr(s);
+ e = exprconvert(expr(s), &typebool);
expect(TRPAREN, "after expression");
label[0] = mkblock("while_cond");
@@ -191,7 +191,7 @@ stmt(struct func *f, struct scope *s)
expect(TWHILE, "after 'do' statement");
expect(TLPAREN, "after 'while'");
funclabel(f, label[1]);
- e = expr(s);
+ e = exprconvert(expr(s), &typebool);
expect(TRPAREN, "after expression");
v = funcexpr(f, e);
@@ -226,7 +226,7 @@ stmt(struct func *f, struct scope *s)
delexpr(e);
}
expect(TSEMICOLON, NULL);
- e = tok.kind == TRPAREN ? NULL : expr(s);
+ e = tok.kind == TRPAREN ? NULL : exprconvert(expr(s), &typebool);
expect(TRPAREN, NULL);
funclabel(f, label[1]);