some indentation made prev patch pretty; removed it

This commit is contained in:
Joe Soroka
2011-03-08 01:59:50 -08:00
parent 89059f94c0
commit 545a37b306

164
tccgen.c
View File

@ -3057,74 +3057,72 @@ static void post_type_args(CType *type, AttributeDef *ad)
AttributeDef ad1; AttributeDef ad1;
CType pt; CType pt;
if (tok == '(') { /* function declaration */
/* function declaration */ next();
next(); l = 0;
l = 0; first = NULL;
first = NULL; plast = &first;
plast = &first; arg_size = 0;
arg_size = 0; if (tok != ')') {
if (tok != ')') { for(;;) {
for(;;) { /* read param name and compute offset */
/* read param name and compute offset */ if (l != FUNC_OLD) {
if (l != FUNC_OLD) { if (!parse_btype(&pt, &ad1)) {
if (!parse_btype(&pt, &ad1)) { if (l) {
if (l) { error("invalid type");
error("invalid type"); } else {
} else { l = FUNC_OLD;
l = FUNC_OLD; goto old_proto;
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");
arg_size += (type_size(&pt, &align) + PTR_SIZE - 1) / PTR_SIZE;
} else {
old_proto:
n = tok;
if (n < TOK_UIDENT)
expect("identifier");
pt.t = VT_INT;
next();
} }
convert_parameter_type(&pt); l = FUNC_NEW;
s = sym_push(n | SYM_FIELD, &pt, 0, 0); if ((pt.t & VT_BTYPE) == VT_VOID && tok == ')')
*plast = s;
plast = &s->next;
if (tok == ')')
break; break;
skip(','); type_decl(&pt, &ad1, &n, TYPE_DIRECT | TYPE_ABSTRACT);
if (l == FUNC_NEW && tok == TOK_DOTS) { if ((pt.t & VT_BTYPE) == VT_VOID)
l = FUNC_ELLIPSIS; error("parameter declared as void");
next(); arg_size += (type_size(&pt, &align) + PTR_SIZE - 1) / PTR_SIZE;
break; } else {
} old_proto:
n = tok;
if (n < TOK_UIDENT)
expect("identifier");
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 == ')')
break;
skip(',');
if (l == FUNC_NEW && tok == TOK_DOTS) {
l = FUNC_ELLIPSIS;
next();
break;
} }
} }
/* if no parameters, then old type prototype */
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);
/* 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()" */
if (tok == '[')
post_type_array(type, ad);
/* 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->ref = s;
} }
/* if no parameters, then old type prototype */
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);
/* 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()" */
if (tok == '[')
post_type_array(type, ad);
/* 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->ref = s;
} }
static void post_type_array(CType *type, AttributeDef *ad) static void post_type_array(CType *type, AttributeDef *ad)
@ -3132,32 +3130,30 @@ static void post_type_array(CType *type, AttributeDef *ad)
int n, t1; int n, t1;
Sym *s; Sym *s;
if (tok == '[') { /* array definition */
/* array definition */ next();
if (tok == TOK_RESTRICT1)
next(); next();
if (tok == TOK_RESTRICT1) n = -1;
next(); if (tok != ']') {
n = -1; n = expr_const();
if (tok != ']') { if (n < 0)
n = expr_const(); error("invalid array size");
if (n < 0) }
error("invalid array size"); skip(']');
} /* parse next post type */
skip(']'); t1 = type->t & VT_STORAGE;
/* parse next post type */ type->t &= ~VT_STORAGE;
t1 = type->t & VT_STORAGE; if (tok == '[')
type->t &= ~VT_STORAGE; post_type_array(type, ad);
if (tok == '[')
post_type_array(type, ad);
/* we push a anonymous symbol which will contain the array /* we push a anonymous symbol which will contain the array
element type */ element type */
s = sym_push(SYM_FIELD, type, 0, n); s = sym_push(SYM_FIELD, type, 0, n);
if (n < 0) if (n < 0)
ARRAY_RESIZE(s->r) = 1; ARRAY_RESIZE(s->r) = 1;
type->t = t1 | VT_ARRAY | VT_PTR; type->t = t1 | VT_ARRAY | VT_PTR;
type->ref = s; type->ref = s;
}
} }
/* Parse a type declaration (except basic type), and return the type /* Parse a type declaration (except basic type), and return the type