diff options
author | Michael Forney <mforney@mforney.org> | 2019-07-03 00:16:16 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-07-03 02:40:53 -0700 |
commit | d875bf74986b87378f80d7be4cd08e8eb8e91c65 (patch) | |
tree | 605f5b0b3339a9f9c049d63cb796f2d44f48ef15 /stmt.c | |
parent | 94ff44d9f3df0ce081bd66c5ebebee660608342b (diff) |
Convert controlling expression of loops to bool
Diffstat (limited to 'stmt.c')
-rw-r--r-- | stmt.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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]); |