aboutsummaryrefslogtreecommitdiff
path: root/expr.c
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-02-13 18:34:41 -0800
committerMichael Forney <mforney@mforney.org>2019-02-13 19:42:25 -0800
commit0dd40e7482785238968dc2c9a36bc2bfd7896df4 (patch)
tree143f49eb959b906e5acc83ea48d20d32916c7ac3 /expr.c
parenta080e36dac54b82beef63580f36cb0da9ad31788 (diff)
Fix decay on qualified array types
Diffstat (limited to 'expr.c')
-rw-r--r--expr.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/expr.c b/expr.c
index 6a28efb..40162f5 100644
--- a/expr.c
+++ b/expr.c
@@ -53,15 +53,21 @@ static struct expression *
decay(struct expression *e)
{
struct expression *old = e;
+ struct type *t;
+ enum typequalifier tq = QUALNONE;
- switch (e->type->kind) {
+ // XXX: combine with decl.c:adjust in some way?
+ t = typeunqual(e->type, &tq);
+ switch (t->kind) {
case TYPEARRAY:
- e = mkexpr(EXPRUNARY, mkpointertype(old->type->base), EXPRFLAG_DECAYED);
+ t = mkqualifiedtype(mkpointertype(old->type->base), tq);
+ e = mkexpr(EXPRUNARY, t, EXPRFLAG_DECAYED);
e->unary.op = TBAND;
e->unary.base = old;
break;
case TYPEFUNC:
- e = mkexpr(EXPRUNARY, mkpointertype(old->type), EXPRFLAG_DECAYED);
+ t = mkpointertype(old->type);
+ e = mkexpr(EXPRUNARY, t, EXPRFLAG_DECAYED);
e->unary.op = TBAND;
e->unary.base = old;
break;