aboutsummaryrefslogtreecommitdiff
path: root/decl.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 /decl.c
parent0288baae5337b95f395a7f3d6c06f14512be5152 (diff)
type: Fix qualifiers of adjusted array types of parameters
Diffstat (limited to 'decl.c')
-rw-r--r--decl.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/decl.c b/decl.c
index 05700f7..23dc778 100644
--- a/decl.c
+++ b/decl.c
@@ -647,12 +647,11 @@ declaratortypes(struct scope *s, struct list *result, char **name, bool allowabs
if (allowattr && attr(NULL, 0))
goto attr;
next();
- tq = QUALNONE;
- while (consume(TSTATIC) || typequal(&tq))
+ t = mkarraytype(NULL, QUALNONE, 0);
+ while (consume(TSTATIC) || typequal(&t->u.array.ptrqual))
;
if (tok.kind == TMUL)
error(&tok.loc, "VLAs are not yet supported");
- t = mkarraytype(NULL, tq, 0);
if (tok.kind != TRBRACK) {
e = eval(assignexpr(s));
if (e->kind != EXPRCONST || !(e->type->prop & PROPINT))
@@ -732,8 +731,9 @@ parameter(struct scope *s)
if (sc && sc != SCREGISTER)
error(&tok.loc, "parameter declaration has invalid storage-class specifier");
t = declarator(s, t, &name, true);
+ t.type = typeadjust(t.type, &t.qual);
- return mkparam(name, typeadjust(t.type), t.qual);
+ return mkparam(name, t.type, t.qual);
}
static bool
@@ -755,7 +755,7 @@ paramdecl(struct scope *s, struct param *params)
;
if (!p)
error(&tok.loc, "old-style function declarator has no parameter named '%s'", name);
- p->type = typeadjust(t.type);
+ p->type = typeadjust(t.type, &t.qual);
p->qual = t.qual;
if (tok.kind == TSEMICOLON)
break;