diff options
| author | 2023-05-29 14:35:18 +0200 | |
|---|---|---|
| committer | 2023-05-30 08:57:37 +0200 | |
| commit | 264c757d66f7b8c469b127cdb64ec9b18f385552 (patch) | |
| tree | 372046067e33eb71968889743913e1aeb477a8e3 /parse.c | |
| parent | 1c04435e5d33378ffa8eca65ca1ed35f3f9f4134 (diff) | |
bugfix with if true branch ending in return
Diffstat (limited to 'parse.c')
| -rw-r--r-- | parse.c | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -1352,7 +1352,7 @@ static void block(struct parser *pr, struct function *fn); static bool /* return 1 if stmt is terminating (all codepaths return) */ stmt(struct parser *pr, struct function *fn) { - struct block *t, *f, *end, *begin; + struct block *tr, *fl, *end, *begin; struct expr ex; union irref r; bool terminates = 0; @@ -1380,25 +1380,25 @@ stmt(struct parser *pr, struct function *fn) expect(pr, ')', NULL); if (!isscalar(ex.ty)) error(&ex.span, "'if' condition is not a scalar (%ty)", ex.ty); - t = f = end = NULL; + tr = fl = end = NULL; EMITS { - t = newblk(fn); - f = newblk(fn); + tr = newblk(fn); + fl = newblk(fn); r = exprvalue(fn, &ex); EMITS { - putjump(fn, Jbcnd, r, t, f); - useblk(fn, t); + putjump(fn, Jbcnd, r, tr, fl); + useblk(fn, tr); } } terminates = stmt(pr, fn); if (!match(pr, NULL, TKWelse)) { - EMITS putjump(fn, Jb, NOREF, f, NULL); - end = f; + end = fl; + EMITS if (!terminates) putjump(fn, Jb, NOREF, end, NULL); terminates = 0; } else { EMITS { if (!terminates) putjump(fn, Jb, NOREF, end = newblk(fn), NULL); - useblk(fn, f); + useblk(fn, fl); } terminates &= stmt(pr, fn); EMITS { @@ -1414,15 +1414,15 @@ stmt(struct parser *pr, struct function *fn) expect(pr, ')', NULL); if (!isscalar(ex.ty)) error(&ex.span, "'while' condition is not a scalar (%ty)", ex.ty); - t = begin = end = NULL; + tr = begin = end = NULL; EMITS { begin = newblk(fn); putjump(fn, Jb, NOREF, begin, NULL); useblk(fn, begin); r = exprvalue(fn, &ex); EMITS { - putjump(fn, Jbcnd, r, t = newblk(fn), end = newblk(fn)); - useblk(fn, t); + putjump(fn, Jbcnd, r, tr = newblk(fn), end = newblk(fn)); + useblk(fn, tr); } } terminates = stmt(pr, fn); |