harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 3184db1d1e98aa7a176d1c8a886310c6a566d052
parent dc9b0da47ac31c64a57be973f78c786b93ba06f1
Author: Eyal Sawady <ecs@d2evs.net>
Date:   Tue, 10 Aug 2021 06:38:36 +0000

gen: fix void return

Diffstat:
Msrc/gen.c | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/gen.c b/src/gen.c @@ -1686,9 +1686,13 @@ static struct gen_value gen_expr_return(struct gen_context *ctx, const struct expression *expr) { struct gen_value ret = gen_expr(ctx, expr->_return.value); - struct qbe_value qret = mkqval(ctx, &ret); gen_defers(ctx); - pushi(ctx->current, NULL, Q_RET, &qret, NULL); + if (type_dealias(ret.type)->storage == STORAGE_VOID) { + pushi(ctx->current, NULL, Q_RET, NULL); + } else { + struct qbe_value qret = mkqval(ctx, &ret); + pushi(ctx->current, NULL, Q_RET, &qret, NULL); + } return gv_void; }