History

anonymous union/struct support (Filip Navara)

bellard committed 21 years ago

Commit 7bc5e511 parent 7b8e2831 file · +14 −3Browse files

Unified · Split

tcc.c+14−3
@@ -6465,7 +6465,7 @@ static void struct_decl(CType *type, int u) · 6464 unmodified lines
6465{6465{
6466 int a, v, size, align, maxalign, c, offset;6466 int a, v, size, align, maxalign, c, offset;
6467 int bit_size, bit_pos, bsize, bt, lbit_pos;6467 int bit_size, bit_pos, bsize, bt, lbit_pos;
6468 Sym *s, *ss, **ps;6468 Sym *s, *ss, *ass, **ps;
6469 AttributeDef ad;6469 AttributeDef ad;
6470 CType type1, btype;6470 CType type1, btype;
6471 6471
@@ -6536,7 +6536,9 @@ static void struct_decl(CType *type, int u) · 64 unmodified lines
6536 v = 0;6536 v = 0;
6537 type1 = btype;6537 type1 = btype;
6538 if (tok != ':') {6538 if (tok != ':') {
6539 type_decl(&type1, &ad, &v, TYPE_DIRECT);6539 type_decl(&type1, &ad, &v, TYPE_DIRECT | TYPE_ABSTRACT);
6540 if (v == 0 && (type1.t & VT_BTYPE) != VT_STRUCT)
6541 expect("identifier");
6540 if ((type1.t & VT_BTYPE) == VT_FUNC ||6542 if ((type1.t & VT_BTYPE) == VT_FUNC ||
6541 (type1.t & (VT_TYPEDEF | VT_STATIC | VT_EXTERN | VT_INLINE)))6543 (type1.t & (VT_TYPEDEF | VT_STATIC | VT_EXTERN | VT_INLINE)))
6542 error("invalid type for '%s'", 6544 error("invalid type for '%s'",
@@ -6599,7 +6601,7 @@ static void struct_decl(CType *type, int u) · 56 unmodified lines
6599 } else {6601 } else {
6600 bit_pos = 0;6602 bit_pos = 0;
6601 }6603 }
6602 if (v) {6604 if (v != 0 || (type1.t & VT_BTYPE) == VT_STRUCT) {
6603 /* add new memory data only if starting6605 /* add new memory data only if starting
6604 bit field */6606 bit field */
6605 if (lbit_pos == 0) {6607 if (lbit_pos == 0) {
@@ -6625,6 +6627,15 @@ static void struct_decl(CType *type, int u) · 19 unmodified lines
6625 }6627 }
6626 printf("\n");6628 printf("\n");
6627#endif6629#endif
6630 }
6631 if (v == 0 && (type1.t & VT_BTYPE) == VT_STRUCT) {
6632 ass = type1.ref;
6633 while ((ass = ass->next) != NULL) {
6634 ss = sym_push(ass->v, &ass->type, 0, offset + ass->c);
6635 *ps = ss;
6636 ps = &ss->next;
6637 }
6638 } else if (v) {
6628 ss = sym_push(v | SYM_FIELD, &type1, 0, offset);6639 ss = sym_push(v | SYM_FIELD, &type1, 0, offset);
6629 *ps = ss;6640 *ps = ss;
6630 ps = &ss->next;6641 ps = &ss->next;

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