mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-17 05:20:08 +08:00
function parameters must be converted to pointer of functions
This commit is contained in:
parent
60b9a1aa38
commit
73acbe2413
17
tcc.c
17
tcc.c
@ -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;
|
||||||
@ -8223,8 +8233,7 @@ static void func_decl_list(Sym *func_sym)
|
|||||||
/* 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 */
|
||||||
|
Loading…
Reference in New Issue
Block a user