aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Soroka <gits@joesoroka.com>2011-03-08 15:12:09 -0800
committerJoe Soroka <gits@joesoroka.com>2011-03-08 15:12:09 -0800
commit9ff91d4c6f6bb20ea5e00d3676559edb6ab374eb (patch)
tree8966453456c8cb6ae05afc17779863984fe35610
parent91163f167e087c419e618186a1aa5589d9f24fde (diff)
downloadtinycc-9ff91d4c6f6bb20ea5e00d3676559edb6ab374eb.tar.gz
tinycc-9ff91d4c6f6bb20ea5e00d3676559edb6ab374eb.tar.bz2
clarify support for functions returning an array (try#2)
fixes first attempt: http://repo.or.cz/w/tinycc.git/commitdiff/31fe1cc
-rw-r--r--tccgen.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/tccgen.c b/tccgen.c
index b335527..fbeb782 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -3108,16 +3108,21 @@ 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;
+ t1 = type->t & VT_STORAGE;
+ type->t &= ~VT_STORAGE;
s = sym_push(SYM_FIELD, type, INT_ATTR(ad), l);
s->next = first;
type->t = t1 | VT_FUNC;