aboutsummaryrefslogtreecommitdiff
path: root/type.c
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2024-04-04 16:46:11 -0700
committerMichael Forney <mforney@mforney.org>2024-04-04 16:54:59 -0700
commit4929ddf5a0f3c5108991e09bcb3592d0db01b77e (patch)
tree0acf92e9cb76bfc45133b99d16d1619e70dd5c0d /type.c
parent0288baae5337b95f395a7f3d6c06f14512be5152 (diff)
type: Fix qualifiers of adjusted array types of parameters
Diffstat (limited to 'type.c')
-rw-r--r--type.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/type.c b/type.c
index 8a9c440..b533f1c 100644
--- a/type.c
+++ b/type.c
@@ -80,6 +80,7 @@ mkarraytype(struct type *base, enum typequal qual, unsigned long long len)
t->base = base;
t->qual = qual;
t->u.array.length = len;
+ t->u.array.ptrqual = QUALNONE;
t->incomplete = !len;
if (t->base) {
t->align = t->base->align;
@@ -225,13 +226,18 @@ typecommonreal(struct type *t1, unsigned w1, struct type *t2, unsigned w2)
/* function parameter type adjustment (C11 6.7.6.3p7) */
struct type *
-typeadjust(struct type *t)
+typeadjust(struct type *t, enum typequal *tq)
{
+ enum typequal ptrqual;
+
switch (t->kind) {
case TYPEARRAY:
- t = mkpointertype(t->base, t->qual);
+ ptrqual = t->u.array.ptrqual;
+ t = mkpointertype(t->base, *tq | t->qual);
+ *tq = ptrqual;
break;
case TYPEFUNC:
+ assert(*tq == QUALNONE);
t = mkpointertype(t, QUALNONE);
break;
}