| @@ -1958,7 +1958,7 @@ ST_FUNC int type_size(CType *type, int *a) · 1957 unmodified lines |
| 1958 | if (bt == VT_STRUCT) { | 1958 | if (bt == VT_STRUCT) { |
| 1959 | /* struct/union */ | 1959 | /* struct/union */ |
| 1960 | s = type->ref; | 1960 | s = type->ref; |
| 1961 | *a = s->r & 0xffffff; | 1961 | *a = s->r; |
| 1962 | return s->c; | 1962 | return s->c; |
| 1963 | } else if (bt == VT_PTR) { | 1963 | } else if (bt == VT_PTR) { |
| 1964 | if (type->t & VT_ARRAY) { | 1964 | if (type->t & VT_ARRAY) { |
| @@ -2610,7 +2610,7 @@ static void parse_attribute(AttributeDef *ad) · 645 unmodified lines |
| 2610 | static void struct_decl(CType *type, int u) | 2610 | static void struct_decl(CType *type, int u) |
| 2611 | { | 2611 | { |
| 2612 | int a, v, size, align, maxalign, c, offset; | 2612 | int a, v, size, align, maxalign, c, offset; |
| 2613 | int bit_size, bit_pos, bsize, bt, lbit_pos, prevbt, resize; | 2613 | int bit_size, bit_pos, bsize, bt, lbit_pos, prevbt; |
| 2614 | Sym *s, *ss, *ass, **ps; | 2614 | Sym *s, *ss, *ass, **ps; |
| 2615 | AttributeDef ad; | 2615 | AttributeDef ad; |
| 2616 | CType type1, btype; | 2616 | CType type1, btype; |
| @@ -2671,7 +2671,6 @@ static void struct_decl(CType *type, int u) · 54 unmodified lines |
| 2671 | } | 2671 | } |
| 2672 | skip('}'); | 2672 | skip('}'); |
| 2673 | } else { | 2673 | } else { |
| 2674 | resize = 0; | | |
| 2675 | maxalign = 1; | 2674 | maxalign = 1; |
| 2676 | ps = &s->next; | 2675 | ps = &s->next; |
| 2677 | prevbt = VT_INT; | 2676 | prevbt = VT_INT; |
| @@ -2762,8 +2761,6 @@ static void struct_decl(CType *type, int u) · 84 unmodified lines |
| 2762 | offset = c; | 2761 | offset = c; |
| 2763 | if (size > 0) | 2762 | if (size > 0) |
| 2764 | c += size; | 2763 | c += size; |
| 2765 | if (size < 0) | | |
| 2766 | resize = 1; | | |
| 2767 | } else { | 2764 | } else { |
| 2768 | offset = 0; | 2765 | offset = 0; |
| 2769 | if (size > c) | 2766 | if (size > c) |
| @@ -2804,7 +2801,7 @@ static void struct_decl(CType *type, int u) · 34 unmodified lines |
| 2804 | skip('}'); | 2801 | skip('}'); |
| 2805 | /* store size and alignment */ | 2802 | /* store size and alignment */ |
| 2806 | s->c = (c + maxalign - 1) & -maxalign; | 2803 | s->c = (c + maxalign - 1) & -maxalign; |
| 2807 | s->r = maxalign | (resize ? (1 << 31) : 0); | 2804 | s->r = maxalign; |
| 2808 | } | 2805 | } |
| 2809 | } | 2806 | } |
| 2810 | } | 2807 | } |
| @@ -3147,8 +3144,6 @@ static void post_type(CType *type, AttributeDef *ad) · 336 unmodified lines |
| 3147 | /* we push a anonymous symbol which will contain the array | 3144 | /* we push a anonymous symbol which will contain the array |
| 3148 | element type */ | 3145 | element type */ |
| 3149 | s = sym_push(SYM_FIELD, type, 0, n); | 3146 | s = sym_push(SYM_FIELD, type, 0, n); |
| 3150 | if (n < 0) | | |
| 3151 | ARRAY_RESIZE(s->r) = 1; | | |
| 3152 | type->t = t1 | VT_ARRAY | VT_PTR; | 3147 | type->t = t1 | VT_ARRAY | VT_PTR; |
| 3153 | type->ref = s; | 3148 | type->ref = s; |
| 3154 | } | 3149 | } |
| @@ -4884,8 +4879,6 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 1729 unmodified lines |
| 4884 | } | 4879 | } |
| 4885 | } else { | 4880 | } else { |
| 4886 | index = 0; | 4881 | index = 0; |
| 4887 | if (ARRAY_RESIZE(s->r)) | | |
| 4888 | n = -1; | | |
| 4889 | while (tok != '}') { | 4882 | while (tok != '}') { |
| 4890 | decl_designator(type, sec, c, &index, NULL, size_only); | 4883 | decl_designator(type, sec, c, &index, NULL, size_only); |
| 4891 | if (n >= 0 && index >= n) | 4884 | if (n >= 0 && index >= n) |
| @@ -4959,8 +4952,6 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 67 unmodified lines |
| 4959 | array_length = 0; | 4952 | array_length = 0; |
| 4960 | index = 0; | 4953 | index = 0; |
| 4961 | n = s->c; | 4954 | n = s->c; |
| 4962 | if (s->r & (1<<31)) | | |
| 4963 | n = -1; | | |
| 4964 | while (tok != '}') { | 4955 | while (tok != '}') { |
| 4965 | decl_designator(type, sec, c, NULL, &f, size_only); | 4956 | decl_designator(type, sec, c, NULL, &f, size_only); |
| 4966 | index = f->c; | 4957 | index = f->c; |
| @@ -4997,7 +4988,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 30 unmodified lines |
| 4997 | skip(','); | 4988 | skip(','); |
| 4998 | } | 4989 | } |
| 4999 | /* put zeros at the end */ | 4990 | /* put zeros at the end */ |
| 5000 | if (!size_only && n >= 0 && array_length < n) { | 4991 | if (!size_only && array_length < n) { |
| 5001 | init_putz(type, sec, c + array_length, | 4992 | init_putz(type, sec, c + array_length, |
| 5002 | n - array_length); | 4993 | n - array_length); |
| 5003 | } | 4994 | } |
| @@ -5007,8 +4998,6 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 3 unmodified lines |
| 5007 | skip(')'); | 4998 | skip(')'); |
| 5008 | par_count--; | 4999 | par_count--; |
| 5009 | } | 5000 | } |
| 5010 | if (n < 0) | | |
| 5011 | s->c = array_length; | | |
| 5012 | } else if (tok == '{') { | 5001 | } else if (tok == '{') { |
| 5013 | next(); | 5002 | next(); |
| 5014 | decl_initializer(type, sec, c, first, size_only); | 5003 | decl_initializer(type, sec, c, first, size_only); |
| @@ -5056,9 +5045,6 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 41 unmodified lines |
| 5056 | TokenString init_str; | 5045 | TokenString init_str; |
| 5057 | Section *sec; | 5046 | Section *sec; |
| 5058 | | 5047 | |
| 5059 | /* resize the struct */ | | |
| 5060 | if ((type->t & VT_BTYPE) == VT_STRUCT && (type->ref->r & (1<<31)) != 0) | | |
| 5061 | type->ref->c = -1; | | |
| 5062 | size = type_size(type, &align); | 5048 | size = type_size(type, &align); |
| 5063 | /* If unknown size, we must evaluate it before | 5049 | /* If unknown size, we must evaluate it before |
| 5064 | evaluating initializers because | 5050 | evaluating initializers because |