diff options
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"); |