harec

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

commit 8a473414daff938cfcbead5d1401de8a04aa9a87
parent 3e4e0d29e6182815116c9b0d0f0815e25fcac780
Author: Drew DeVault <sir@cmpwn.com>
Date:   Mon,  1 Feb 2021 17:56:39 -0500

gen: handle discarded match case result

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

diff --git a/src/gen.c b/src/gen.c @@ -895,18 +895,22 @@ gen_cast_to_tagged(struct gen_context *ctx, // TODO: check should lower this to multiple casts: assert(subtype->id == from->id); - constw(&tag, subtype->id); - pushi(ctx->current, &ptr, Q_COPY, out, NULL); - pushi(ctx->current, NULL, Q_STOREW, &tag, &ptr, NULL); + if (out) { + constw(&tag, subtype->id); + pushi(ctx->current, &ptr, Q_COPY, out, NULL); + pushi(ctx->current, NULL, Q_STOREW, &tag, &ptr, NULL); + } struct qbe_value *storage; if (expr->cast.value->result->size == 0) { storage = NULL; - } else { + } else if (out) { pushi(ctx->current, &ptr, Q_ADD, &ptr, &offs, NULL); ptr.type = qtype_for_type(ctx, expr->cast.value->result, false); qval_deref(&ptr); storage = &ptr; + } else { + storage = NULL; } gen_expression(ctx, expr->cast.value, storage);