aboutsummaryrefslogtreecommitdiff
path: root/tccgen.c
diff options
context:
space:
mode:
authorJoe Soroka <gits@joesoroka.com>2011-03-08 01:59:50 -0800
committerJoe Soroka <gits@joesoroka.com>2011-03-08 01:59:50 -0800
commit545a37b306c30ca5a164cbf06d6a13b8c40cbc83 (patch)
treefcbf43bb31be4e5c396637bfa1aaca5c879e92d4 /tccgen.c
parent89059f94c08b6da87fcbd98fba2b5876c0bde3bd (diff)
downloadtinycc-545a37b306c30ca5a164cbf06d6a13b8c40cbc83.tar.gz
tinycc-545a37b306c30ca5a164cbf06d6a13b8c40cbc83.tar.bz2
some indentation made prev patch pretty; removed it
Diffstat (limited to 'tccgen.c')
-rw-r--r--tccgen.c166
1 files changed, 81 insertions, 85 deletions
diff --git a/tccgen.c b/tccgen.c
index c4c3c46..15736f0 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -3057,74 +3057,72 @@ static void post_type_args(CType *type, AttributeDef *ad)
AttributeDef ad1;
CType pt;
- if (tok == '(') {
- /* function declaration */
- next();
- l = 0;
- first = NULL;
- plast = &first;
- arg_size = 0;
- 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;
- }
+ /* function declaration */
+ next();
+ l = 0;
+ first = NULL;
+ plast = &first;
+ arg_size = 0;
+ 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");
- 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);
- 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();
+ 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);
+ 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)
@@ -3132,32 +3130,30 @@ static void post_type_array(CType *type, AttributeDef *ad)
int n, t1;
Sym *s;
- if (tok == '[') {
- /* array definition */
+ /* array definition */
+ next();
+ if (tok == TOK_RESTRICT1)
next();
- if (tok == TOK_RESTRICT1)
- next();
- n = -1;
- if (tok != ']') {
- n = expr_const();
- if (n < 0)
- error("invalid array size");
- }
- skip(']');
- /* parse next post type */
- t1 = type->t & VT_STORAGE;
- type->t &= ~VT_STORAGE;
- if (tok == '[')
- post_type_array(type, ad);
-
- /* we push a anonymous symbol which will contain the array
- element type */
- s = sym_push(SYM_FIELD, type, 0, n);
+ n = -1;
+ if (tok != ']') {
+ n = expr_const();
+ if (n < 0)
+ error("invalid array size");
+ }
+ skip(']');
+ /* parse next post type */
+ t1 = type->t & VT_STORAGE;
+ type->t &= ~VT_STORAGE;
+ if (tok == '[')
+ post_type_array(type, ad);
+
+ /* we push a anonymous symbol which will contain the array
+ element type */
+ s = sym_push(SYM_FIELD, type, 0, n);
if (n < 0)
ARRAY_RESIZE(s->r) = 1;
- type->t = t1 | VT_ARRAY | VT_PTR;
- type->ref = s;
- }
+ type->t = t1 | VT_ARRAY | VT_PTR;
+ type->ref = s;
}
/* Parse a type declaration (except basic type), and return the type