Emit code for address expressions

It helps if the necessary code is actually emitted in the first place.
This commit is contained in:
Bill Currie 2019-06-09 21:21:41 +09:00
parent 8cef85e5de
commit f49303e774
2 changed files with 7 additions and 4 deletions

View file

@ -2238,6 +2238,7 @@ address_expr (expr_t *e1, expr_t *e2, type_t *t)
return new_label_ref (&e1->e.label);
case ex_temp:
e = new_unary_expr ('&', e1);
e->e.expr.type = pointer_type (t);
break;
default:
return error (e1, "invalid type for unary &");

View file

@ -706,10 +706,12 @@ expr_call (sblock_t *sblock, expr_t *call, operand_t **op)
static sblock_t *
expr_address (sblock_t *sblock, expr_t *e, operand_t **op)
{
if (e->type == ex_uexpr) {
sblock = statement_subexpr (sblock, e->e.expr.e1, op);
(*op)->type = ev_pointer;
}
statement_t *s;
s = new_statement (st_expr, "&", e);
sblock = statement_subexpr (sblock, e->e.expr.e1, &s->opa);
s->opc = temp_operand (e->e.expr.type);
sblock_add_statement (sblock, s);
*(op) = s->opc;
return sblock;
}