From dddbdcbeb41777c1e98e37281dddd6f3c89a1280 Mon Sep 17 00:00:00 2001 From: lemon Date: Mon, 8 Aug 2022 19:31:35 +0200 Subject: ok --- bootstrap/cgen.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'bootstrap/cgen.c') 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"); -- cgit v1.2.3