diff options
| author | 2022-08-08 19:31:35 +0200 | |
|---|---|---|
| committer | 2022-08-08 19:31:35 +0200 | |
| commit | dddbdcbeb41777c1e98e37281dddd6f3c89a1280 (patch) | |
| tree | 6c172f13a3d7d92bc31b8a045d81b7fa7caad007 /bootstrap/cgen.c | |
| parent | fc55daf22dd890860ac9c1a0a29900977a700df2 (diff) | |
ok
Diffstat (limited to 'bootstrap/cgen.c')
| -rw-r--r-- | bootstrap/cgen.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/bootstrap/cgen.c b/bootstrap/cgen.c index 3151edf..62a808d 100644 --- a/bootstrap/cgen.c +++ b/bootstrap/cgen.c @@ -240,7 +240,7 @@ genexpr(struct expr *ex) { goto intlit; break; case Ezeroini: - if (ty->t == TYarr || ty->t == TYstruct) + if (ty->t == TYarr || ty->t == TYstruct || ty->t == TYunion || ty->t == TYeunion || ty->t == TYslice) pri("((%t){0})", ty); else pri("((%t)0)", ty); @@ -699,12 +699,15 @@ defctype(const struct type *ty, void *_) { *cname = xasprintf("__ty%s%d", ty->agg.name ? ty->agg.name : "", id++); pri("typedef %s %s %s;\n", kind, *cname, *cname); if (!ty->agg.fwd) { + for (int i = 0; i < ty->agg.flds.n; ++i) { + struct aggfield fld = ty->agg.flds.d[i]; + defctype(fld.ty, NULL); + } pri("%s %s {\n", kind, *cname); if (!ty->agg.flds.n) pri("char _;\n"); for (int i = 0; i < ty->agg.flds.n; ++i) { struct aggfield fld = ty->agg.flds.d[i]; - defctype(ty->agg.flds.d[i].ty, NULL); pri("%t %s;\n", fld.ty, fld.name); } pri("};\n"); |