diff options
| author | Joe Soroka <gits@joesoroka.com> | 2011-03-08 14:13:08 -0800 |
|---|---|---|
| committer | Joe Soroka <gits@joesoroka.com> | 2011-03-08 14:13:08 -0800 |
| commit | 31fe1cc62b30e52d35dfd669dc9bc3dbb5a8ad8e (patch) | |
| tree | 5be2fcc3b843256556fa55218fd5fbab3268b459 /tccgen.c | |
| parent | 5eb82755db1e46a4c7cb7ded62d8176daf1da572 (diff) | |
| download | tinycc-31fe1cc62b30e52d35dfd669dc9bc3dbb5a8ad8e.tar.gz tinycc-31fe1cc62b30e52d35dfd669dc9bc3dbb5a8ad8e.tar.bz2 | |
clarify support for functions returning an array
previously, tcc would accept a prototype of a function returning
an array, but not giving those functions bodies nor calling them.
it seems that gcc has never supported them, so we should probably
just error out... but it's possible that someone already using
tcc includes some header that contains an unused prototype for
one, so let's continue to support that.
Diffstat (limited to 'tccgen.c')
| -rw-r--r-- | tccgen.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -3108,19 +3108,22 @@ static void post_type(CType *type, AttributeDef *ad) if (l == 0) l = FUNC_OLD; skip(')'); - t1 = type->t & VT_STORAGE; /* NOTE: const is ignored in returned type as it has a special meaning in gcc / C++ */ - type->t &= ~(VT_STORAGE | VT_CONSTANT); + type->t &= ~VT_CONSTANT; /* some ancient pre-K&R C allows a function to return an array and the array brackets to be put after the arguments, such - that "int c()[]" means the same as "int[] c()" */ - post_type(type, ad); + that "int c()[]" means something like "int[] c()" */ + if (tok == '[') { + next(); + skip(']'); /* only handle simple "[]" */ + type->t |= VT_PTR; + } /* we push a anonymous symbol which will contain the function prototype */ ad->func_args = arg_size; s = sym_push(SYM_FIELD, type, INT_ATTR(ad), l); s->next = first; - type->t = t1 | VT_FUNC; + type->t |= VT_FUNC; type->ref = s; } else if (tok == '[') { /* array definition */ |
