forked from Mirrors/tinycc
fixed parsing of function parameters
parent
7bc5e51847
commit
62c5a5466a
56
tcc.c
56
tcc.c
|
@ -6853,35 +6853,39 @@ static void post_type(CType *type, AttributeDef *ad)
|
||||||
l = 0;
|
l = 0;
|
||||||
first = NULL;
|
first = NULL;
|
||||||
plast = &first;
|
plast = &first;
|
||||||
while (tok != ')') {
|
if (tok != ')') {
|
||||||
/* read param name and compute offset */
|
for(;;) {
|
||||||
if (l != FUNC_OLD) {
|
/* read param name and compute offset */
|
||||||
if (!parse_btype(&pt, &ad1)) {
|
if (l != FUNC_OLD) {
|
||||||
if (l) {
|
if (!parse_btype(&pt, &ad1)) {
|
||||||
error("invalid type");
|
if (l) {
|
||||||
} else {
|
error("invalid type");
|
||||||
l = FUNC_OLD;
|
} else {
|
||||||
goto old_proto;
|
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;
|
convert_parameter_type(&pt);
|
||||||
if ((pt.t & VT_BTYPE) == VT_VOID && tok == ')')
|
s = sym_push(n | SYM_FIELD, &pt, 0, 0);
|
||||||
|
*plast = s;
|
||||||
|
plast = &s->next;
|
||||||
|
if (tok == ')')
|
||||||
break;
|
break;
|
||||||
type_decl(&pt, &ad1, &n, TYPE_DIRECT | TYPE_ABSTRACT);
|
skip(',');
|
||||||
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();
|
|
||||||
if (l == FUNC_NEW && tok == TOK_DOTS) {
|
if (l == FUNC_NEW && tok == TOK_DOTS) {
|
||||||
l = FUNC_ELLIPSIS;
|
l = FUNC_ELLIPSIS;
|
||||||
next();
|
next();
|
||||||
|
|
Loading…
Reference in New Issue