aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2024-04-27 01:11:36 -0700
committerMichael Forney <mforney@mforney.org>2024-04-27 01:12:22 -0700
commit85dd122f81322a6de30e547ada17cf8ccf4869fd (patch)
treea15093bd30008a747c5f01bfda6b77493a3c6c3e
parent54abcd563ddb7012a7eb19dc1397570f4b6d58a5 (diff)
qbe: Use expression type when loading
If we are loading the first element of an array, or first member of a structure, the expression type may be different from the object type.
-rw-r--r--qbe.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/qbe.c b/qbe.c
index f76f792..a6781dd 100644
--- a/qbe.c
+++ b/qbe.c
@@ -678,7 +678,7 @@ funcexpr(struct func *f, struct expr *e)
case EXPRIDENT:
d = e->u.ident.decl;
switch (d->kind) {
- case DECLOBJECT: return funcload(f, d->type, (struct lvalue){d->value});
+ case DECLOBJECT: return funcload(f, e->type, (struct lvalue){d->value});
case DECLCONST: return d->value;
default:
fatal("unimplemented declaration kind %d", d->kind);