History

revert complicated & broken flexible array member handling

Joe Soroka committed 15 years ago

Commit 06a7c411 parent 4062d782 files · +5 −21Browse files

Unified · Split

2 files
  1. tcc.h +1 −3
  2. tccgen.c +4 −18
tcc.h+1−3
@@ -282,8 +282,7 @@ typedef struct AttributeDef { · 281 unmodified lines
282282 func_args : 5,
283283 mode : 4,
284284 weak : 1,
285− resize : 1,
286− fill : 10;
285+ fill : 11;
287286 struct Section *section;
288287 int alias_target; /* token */
289288 } AttributeDef;
@@ -295,7 +294,6 @@ typedef struct AttributeDef { · 5 unmodified lines
295294 #define FUNC_ARGS(r) (((AttributeDef*)&(r))->func_args)
296295 #define FUNC_ALIGN(r) (((AttributeDef*)&(r))->aligned)
297296 #define FUNC_PACKED(r) (((AttributeDef*)&(r))->packed)
298−#define ARRAY_RESIZE(r) (((AttributeDef*)&(r))->resize)
299297 #define ATTR_MODE(r) (((AttributeDef*)&(r))->mode)
300298 #define INT_ATTR(ad) (*(int*)(ad))
301299
tccgen.c+4−18
@@ -1958,7 +1958,7 @@ ST_FUNC int type_size(CType *type, int *a) · 1957 unmodified lines
19581958 if (bt == VT_STRUCT) {
19591959 /* struct/union */
19601960 s = type->ref;
1961− *a = s->r & 0xffffff;
1961+ *a = s->r;
19621962 return s->c;
19631963 } else if (bt == VT_PTR) {
19641964 if (type->t & VT_ARRAY) {
@@ -2610,7 +2610,7 @@ static void parse_attribute(AttributeDef *ad) · 645 unmodified lines
26102610 static void struct_decl(CType *type, int u)
26112611 {
26122612 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;
26142614 Sym *s, *ss, *ass, **ps;
26152615 AttributeDef ad;
26162616 CType type1, btype;
@@ -2671,7 +2671,6 @@ static void struct_decl(CType *type, int u) · 54 unmodified lines
26712671 }
26722672 skip('}');
26732673 } else {
2674− resize = 0;
26752674 maxalign = 1;
26762675 ps = &s->next;
26772676 prevbt = VT_INT;
@@ -2762,8 +2761,6 @@ static void struct_decl(CType *type, int u) · 84 unmodified lines
27622761 offset = c;
27632762 if (size > 0)
27642763 c += size;
2765− if (size < 0)
2766− resize = 1;
27672764 } else {
27682765 offset = 0;
27692766 if (size > c)
@@ -2804,7 +2801,7 @@ static void struct_decl(CType *type, int u) · 34 unmodified lines
28042801 skip('}');
28052802 /* store size and alignment */
28062803 s->c = (c + maxalign - 1) & -maxalign;
2807− s->r = maxalign | (resize ? (1 << 31) : 0);
2804+ s->r = maxalign;
28082805 }
28092806 }
28102807 }
@@ -3147,8 +3144,6 @@ static void post_type(CType *type, AttributeDef *ad) · 336 unmodified lines
31473144 /* we push a anonymous symbol which will contain the array
31483145 element type */
31493146 s = sym_push(SYM_FIELD, type, 0, n);
3150− if (n < 0)
3151− ARRAY_RESIZE(s->r) = 1;
31523147 type->t = t1 | VT_ARRAY | VT_PTR;
31533148 type->ref = s;
31543149 }
@@ -4884,8 +4879,6 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 1729 unmodified lines
48844879 }
48854880 } else {
48864881 index = 0;
4887− if (ARRAY_RESIZE(s->r))
4888− n = -1;
48894882 while (tok != '}') {
48904883 decl_designator(type, sec, c, &index, NULL, size_only);
48914884 if (n >= 0 && index >= n)
@@ -4959,8 +4952,6 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 67 unmodified lines
49594952 array_length = 0;
49604953 index = 0;
49614954 n = s->c;
4962− if (s->r & (1<<31))
4963− n = -1;
49644955 while (tok != '}') {
49654956 decl_designator(type, sec, c, NULL, &f, size_only);
49664957 index = f->c;
@@ -4997,7 +4988,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 30 unmodified lines
49974988 skip(',');
49984989 }
49994990 /* put zeros at the end */
5000− if (!size_only && n >= 0 && array_length < n) {
4991+ if (!size_only && array_length < n) {
50014992 init_putz(type, sec, c + array_length,
50024993 n - array_length);
50034994 }
@@ -5007,8 +4998,6 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 3 unmodified lines
50074998 skip(')');
50084999 par_count--;
50095000 }
5010− if (n < 0)
5011− s->c = array_length;
50125001 } else if (tok == '{') {
50135002 next();
50145003 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
50565045 TokenString init_str;
50575046 Section *sec;
50585047
5059− /* resize the struct */
5060− if ((type->t & VT_BTYPE) == VT_STRUCT && (type->ref->r & (1<<31)) != 0)
5061− type->ref->c = -1;
50625048 size = type_size(type, &align);
50635049 /* If unknown size, we must evaluate it before
50645050 evaluating initializers because

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t