harec

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

commit ed6140b383e8f9824912b7d7b9bbb38ab8b0e377
parent 5cd5f8c5b80531d42586b9fde52b919c9f4b1aec
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sun, 24 Jan 2021 11:52:18 -0500

gen: fix issues with assign+mutate operators

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

diff --git a/src/gen.c b/src/gen.c @@ -615,10 +615,18 @@ gen_expr_assign(struct gen_context *ctx, struct expression *object = expr->assign.object; assert(object->type == EXPR_ACCESS || expr->assign.indirect); // Invariant + const struct expression *value = expr->assign.value; + const struct type *objtype = expr->assign.indirect + ? object->result->pointer.referent : object->result; + const struct qbe_type *vtype = + qtype_for_type(ctx, value->result, true); + const struct qbe_type *otype = qtype_for_type(ctx, objtype, true); + struct qbe_value src = {0}; if (expr->assign.indirect) { gen_temp(ctx, &src, &qbe_long, "indirect.%d"); // XXX: ARCH gen_expression(ctx, object, &src); + src.type = otype; qval_deref(&src); } else { const struct expression *object = expr->assign.object; @@ -626,13 +634,6 @@ gen_expr_assign(struct gen_context *ctx, src.type = qtype_for_type(ctx, object->result, true); } - const struct expression *value = expr->assign.value; - const struct type *objtype = expr->assign.indirect - ? object->result->pointer.referent : object->result; - const struct qbe_type *vtype = - qtype_for_type(ctx, value->result, false); - const struct qbe_type *otype = qtype_for_type(ctx, objtype, false); - if (expr->assign.op == BIN_LEQUAL) { if (!type_is_aggregate(value->result)) { qval_deref(&src);