diff options
| author | bellard <bellard> | 2003-04-13 14:30:32 +0000 |
|---|---|---|
| committer | bellard <bellard> | 2003-04-13 14:30:32 +0000 |
| commit | 73acbe241320c6643e0222fce6eadec8a4833c1d (patch) | |
| tree | f66b2b9be6328b892b72d62d3471f3587d9013de /tcc.c | |
| parent | 60b9a1aa3868546b935dbd62e13f8f7a922e40c6 (diff) | |
| download | tinycc-73acbe241320c6643e0222fce6eadec8a4833c1d.tar.gz tinycc-73acbe241320c6643e0222fce6eadec8a4833c1d.tar.bz2 | |
function parameters must be converted to pointer of functions
Diffstat (limited to 'tcc.c')
| -rw-r--r-- | tcc.c | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -6147,6 +6147,17 @@ the_end: 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) { int n, l, t1; @@ -6183,8 +6194,7 @@ static void post_type(CType *type, AttributeDef *ad) pt.t = VT_INT; next(); } - /* array must be transformed to pointer according to ANSI C */ - pt.t &= ~VT_ARRAY; + convert_parameter_type(&pt); s = sym_push(n | SYM_FIELD, &pt, 0, 0); *plast = s; plast = &s->next; @@ -8222,9 +8232,8 @@ static void func_decl_list(Sym *func_sym) found: /* check that no storage specifier except 'register' was given */ if (type.t & VT_STORAGE) - error("storage class specified for '%s'", get_tok_str(v, NULL)); - /* array must be transformed to pointer according to ANSI C */ - type.t &= ~VT_ARRAY; + error("storage class specified for '%s'", get_tok_str(v, NULL)); + convert_parameter_type(&type); /* we can add the type (NOTE: it could be local to the function) */ s->type = type; /* accept other parameters */ |
