diff options
| author | bellard <bellard> | 2005-09-03 22:51:34 +0000 |
|---|---|---|
| committer | bellard <bellard> | 2005-09-03 22:51:34 +0000 |
| commit | 62c5a5466ab19ef2c9ce3d88289549f19ae8fcb8 (patch) | |
| tree | 752a237ebc4a2cd0bae51a7bbd23185193c7efd6 /tcc.c | |
| parent | 7bc5e518478b6336445c15b18872d4aed96771df (diff) | |
| download | tinycc-62c5a5466ab19ef2c9ce3d88289549f19ae8fcb8.tar.gz tinycc-62c5a5466ab19ef2c9ce3d88289549f19ae8fcb8.tar.bz2 | |
fixed parsing of function parameters
Diffstat (limited to 'tcc.c')
| -rw-r--r-- | tcc.c | 56 |
1 files changed, 30 insertions, 26 deletions
@@ -6853,35 +6853,39 @@ static void post_type(CType *type, AttributeDef *ad) l = 0; first = NULL; plast = &first; - while (tok != ')') { - /* read param name and compute offset */ - if (l != FUNC_OLD) { - if (!parse_btype(&pt, &ad1)) { - if (l) { - error("invalid type"); - } else { - l = FUNC_OLD; - goto old_proto; + if (tok != ')') { + for(;;) { + /* read param name and compute offset */ + if (l != FUNC_OLD) { + if (!parse_btype(&pt, &ad1)) { + if (l) { + error("invalid type"); + } else { + l = FUNC_OLD; + goto old_proto; + } } + l = FUNC_NEW; + if ((pt.t & VT_BTYPE) == VT_VOID && tok == ')') + break; + type_decl(&pt, &ad1, &n, TYPE_DIRECT | TYPE_ABSTRACT); + if ((pt.t & VT_BTYPE) == VT_VOID) + error("parameter declared as void"); + } else { + old_proto: + n = tok; + if (n < TOK_UIDENT) + expect("identifier"); + pt.t = VT_INT; + next(); } - l = FUNC_NEW; - if ((pt.t & VT_BTYPE) == VT_VOID && tok == ')') + convert_parameter_type(&pt); + s = sym_push(n | SYM_FIELD, &pt, 0, 0); + *plast = s; + plast = &s->next; + if (tok == ')') break; - type_decl(&pt, &ad1, &n, TYPE_DIRECT | TYPE_ABSTRACT); - if ((pt.t & VT_BTYPE) == VT_VOID) - error("parameter declared as void"); - } else { - old_proto: - n = tok; - pt.t = VT_INT; - next(); - } - convert_parameter_type(&pt); - s = sym_push(n | SYM_FIELD, &pt, 0, 0); - *plast = s; - plast = &s->next; - if (tok == ',') { - next(); + skip(','); if (l == FUNC_NEW && tok == TOK_DOTS) { l = FUNC_ELLIPSIS; next(); |
