commit 83c47446b030f8abd1c7b635d41bdd84fc10f8b0
parent a47da4831e6000e825decbeb876cfc604082d41f
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Sun, 16 Nov 2014 06:17:03 -0500
Check type of function parameters
Not all the types are valid for functions (for example function parameters),
and it is also needed decay the array types to pointers.
Diffstat:
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/cc1/decl.c b/cc1/decl.c
@@ -383,8 +383,11 @@ parameter(void)
if ((tp = specifier(&sclass)) == voidtype)
return tp;
sym = declarator(tp, ID_ACCEPTED, NS_IDEN);
- sym->s.isdefined = 1;
- /* TODO: check type of the parameter */
+ tp = sym->type;
+ if (tp->op == FTN)
+ error("incorrect function type for a function parameter");
+ if (tp->op == ARY)
+ tp = mktype(tp->type, PTR, 0, NULL);
switch (sclass) {
case REGISTER:
sym->s.isregister = 1;
@@ -395,7 +398,7 @@ parameter(void)
default:
error("bad storage class in function parameter");
}
- return sym->type;
+ return tp;
}
void