function parameters must be converted to pointer of functions

tcc-xref
bellard 2003-04-13 14:30:32 +00:00
parent 60b9a1aa38
commit 73acbe2413
1 changed files with 14 additions and 5 deletions

19
tcc.c
View File

@ -6147,6 +6147,17 @@ the_end:
return type_found; return type_found;
} }
/* convert a function parameter type (array to pointer and function to
function pointer) */
static inline void convert_parameter_type(CType *pt)
{
/* array must be transformed to pointer according to ANSI C */
pt->t &= ~VT_ARRAY;
if ((pt->t & VT_BTYPE) == VT_FUNC) {
mk_pointer(pt);
}
}
static void post_type(CType *type, AttributeDef *ad) static void post_type(CType *type, AttributeDef *ad)
{ {
int n, l, t1; int n, l, t1;
@ -6183,8 +6194,7 @@ static void post_type(CType *type, AttributeDef *ad)
pt.t = VT_INT; pt.t = VT_INT;
next(); next();
} }
/* array must be transformed to pointer according to ANSI C */ convert_parameter_type(&pt);
pt.t &= ~VT_ARRAY;
s = sym_push(n | SYM_FIELD, &pt, 0, 0); s = sym_push(n | SYM_FIELD, &pt, 0, 0);
*plast = s; *plast = s;
plast = &s->next; plast = &s->next;
@ -8222,9 +8232,8 @@ static void func_decl_list(Sym *func_sym)
found: found:
/* check that no storage specifier except 'register' was given */ /* check that no storage specifier except 'register' was given */
if (type.t & VT_STORAGE) if (type.t & VT_STORAGE)
error("storage class specified for '%s'", get_tok_str(v, NULL)); error("storage class specified for '%s'", get_tok_str(v, NULL));
/* array must be transformed to pointer according to ANSI C */ convert_parameter_type(&type);
type.t &= ~VT_ARRAY;
/* we can add the type (NOTE: it could be local to the function) */ /* we can add the type (NOTE: it could be local to the function) */
s->type = type; s->type = type;
/* accept other parameters */ /* accept other parameters */