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
64656465 {
64666466 int a, v, size, align, maxalign, c, offset;
64676467 int bit_size, bit_pos, bsize, bt, lbit_pos;
6468− Sym *s, *ss, **ps;
6468+ Sym *s, *ss, *ass, **ps;
64696469 AttributeDef ad;
64706470 CType type1, btype;
64716471
@@ -6536,7 +6536,9 @@ static void struct_decl(CType *type, int u) · 64 unmodified lines
65366536 v = 0;
65376537 type1 = btype;
65386538 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");
65406542 if ((type1.t & VT_BTYPE) == VT_FUNC ||
65416543 (type1.t & (VT_TYPEDEF | VT_STATIC | VT_EXTERN | VT_INLINE)))
65426544 error("invalid type for '%s'",
@@ -6599,7 +6601,7 @@ static void struct_decl(CType *type, int u) · 56 unmodified lines
65996601 } else {
66006602 bit_pos = 0;
66016603 }
6602− if (v) {
6604+ if (v != 0 || (type1.t & VT_BTYPE) == VT_STRUCT) {
66036605 /* add new memory data only if starting
66046606 bit field */
66056607 if (lbit_pos == 0) {
@@ -6625,6 +6627,15 @@ static void struct_decl(CType *type, int u) · 19 unmodified lines
66256627 }
66266628 printf("\n");
66276629 #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) {
66286639 ss = sym_push(v | SYM_FIELD, &type1, 0, offset);
66296640 *ps = ss;
66306641 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