Unified · Split
| @@ -3048,7 +3048,9 @@ static void asm_label_instr(CString *astr) · 3047 unmodified lines | ||
| 3048 | 3048 | #endif |
| 3049 | 3049 | } |
| 3050 | 3050 | |
| 3051 | −static void post_type(CType *type, AttributeDef *ad) | |
| 3051 | +static void post_type_array(CType *type, AttributeDef *ad); | |
| 3052 | + | |
| 3053 | +static void post_type_args(CType *type, AttributeDef *ad) | |
| 3052 | 3054 | { |
| 3053 | 3055 | int n, l, t1, arg_size, align; |
| 3054 | 3056 | Sym **plast, *s, *first; |
| @@ -3114,14 +3116,23 @@ static void post_type(CType *type, AttributeDef *ad) · 59 unmodified lines | ||
| 3114 | 3116 | /* some ancient pre-K&R C allows a function to return an array |
| 3115 | 3117 | and the array brackets to be put after the arguments, such |
| 3116 | 3118 | that "int c()[]" means the same as "int[] c()" */ |
| 3117 | − post_type(type, ad); | |
| 3119 | + if (tok == '[') | |
| 3120 | + post_type_array(type, ad); | |
| 3118 | 3121 | /* we push a anonymous symbol which will contain the function prototype */ |
| 3119 | 3122 | ad->func_args = arg_size; |
| 3120 | 3123 | s = sym_push(SYM_FIELD, type, INT_ATTR(ad), l); |
| 3121 | 3124 | s->next = first; |
| 3122 | 3125 | type->t = t1 | VT_FUNC; |
| 3123 | 3126 | type->ref = s; |
| 3124 | − } else if (tok == '[') { | |
| 3127 | + } | |
| 3128 | +} | |
| 3129 | + | |
| 3130 | +static void post_type_array(CType *type, AttributeDef *ad) | |
| 3131 | +{ | |
| 3132 | + int n, t1; | |
| 3133 | + Sym *s; | |
| 3134 | + | |
| 3135 | + if (tok == '[') { | |
| 3125 | 3136 | /* array definition */ |
| 3126 | 3137 | next(); |
| 3127 | 3138 | if (tok == TOK_RESTRICT1) |
| @@ -3136,7 +3147,8 @@ static void post_type(CType *type, AttributeDef *ad) · 8 unmodified lines | ||
| 3136 | 3147 | /* parse next post type */ |
| 3137 | 3148 | t1 = type->t & VT_STORAGE; |
| 3138 | 3149 | type->t &= ~VT_STORAGE; |
| 3139 | − post_type(type, ad); | |
| 3150 | + if (tok == '[') | |
| 3151 | + post_type_array(type, ad); | |
| 3140 | 3152 | |
| 3141 | 3153 | /* we push a anonymous symbol which will contain the array |
| 3142 | 3154 | element type */ |
| @@ -3210,7 +3222,10 @@ static void type_decl(CType *type, AttributeDef *ad, int *v, int td) · 67 unmodified lines | ||
| 3210 | 3222 | *v = 0; |
| 3211 | 3223 | } |
| 3212 | 3224 | } |
| 3213 | − post_type(type, ad); | |
| 3225 | + if (tok == '(') | |
| 3226 | + post_type_args(type, ad); | |
| 3227 | + else if (tok == '[') | |
| 3228 | + post_type_array(type, ad); | |
| 3214 | 3229 | if (tok == TOK_ATTRIBUTE1 || tok == TOK_ATTRIBUTE2) |
| 3215 | 3230 | parse_attribute(ad); |
| 3216 | 3231 | |