cproc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/cproc
Log | Files | Refs | Submodules | README | LICENSE

commit 0dd40e7482785238968dc2c9a36bc2bfd7896df4
parent a080e36dac54b82beef63580f36cb0da9ad31788
Author: Michael Forney <mforney@mforney.org>
Date:   Wed, 13 Feb 2019 18:34:41 -0800

Fix decay on qualified array types

Diffstat:
Mexpr.c | 12+++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git 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;