diff options
| author | Quentin Carbonneaux <[email protected]> | 2022-03-08 15:49:01 +0100 |
|---|---|---|
| committer | Quentin Carbonneaux <[email protected]> | 2022-03-08 15:57:06 +0100 |
| commit | 9060981c10c21834596d5677a2c9ccc56809eb64 (patch) | |
| tree | 2fe18c42b4c435a15612abdc4ce836d5860cdfa2 /parse.c | |
| parent | 349794f3e4f11e4cc34a501ba935a2a305229738 (diff) | |
flag types defined as unions
The risc-v abi needs to know if a
type is defined as a union or not.
We cannot use nunion to obtain this
information because the risc-v abi
made the unfortunate decision of
treating
union { int i; }
differently from
int i;
So, instead, I introduce a single
bit flag 'isunion'.
Diffstat (limited to 'parse.c')
| -rw-r--r-- | parse.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -925,7 +925,8 @@ parsetyp() */ vgrow(&typ, ntyp+1); ty = &typ[ntyp++]; - ty->dark = 0; + ty->isdark = 0; + ty->isunion = 0; ty->align = -1; ty->size = 0; if (nextnl() != Ttyp || nextnl() != Teq) @@ -944,7 +945,7 @@ parsetyp() err("type body must start with {"); t = nextnl(); if (t == Tint) { - ty->dark = 1; + ty->isdark = 1; ty->size = tokval.num; if (ty->align == -1) err("dark types need alignment"); @@ -954,7 +955,8 @@ parsetyp() } n = 0; ty->fields = vnew(1, sizeof ty->fields[0], Pheap); - if (t == Tlbrace) + if (t == Tlbrace) { + ty->isunion = 1; do { if (t != Tlbrace) err("invalid union member"); @@ -962,7 +964,7 @@ parsetyp() parsefields(ty->fields[n++], ty, nextnl()); t = nextnl(); } while (t != Trbrace); - else + } else parsefields(ty->fields[n++], ty, t); ty->nunion = n; } |
