From b33ee6afa74ab1e83554d1b535d81c7df0b3fca5 Mon Sep 17 00:00:00 2001 From: lemon Date: Wed, 10 Aug 2022 04:12:33 +0200 Subject: many bugfix --- bootstrap/env.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'bootstrap/env.c') diff --git a/bootstrap/env.c b/bootstrap/env.c index 601b446..2c5e80f 100644 --- a/bootstrap/env.c +++ b/bootstrap/env.c @@ -32,13 +32,19 @@ envput(struct env *env, const struct decl *decl) { static int age; if ((d0 = envfind(&env_noparent, INT_MAX, decl->name))) { + if (decl == d0 || !memcmp(d0, decl, sizeof *d0)) + return d0; // modify existing forward declarations? + if (d0->t != decl->t) + return NULL; + if (d0->t == Dmacro && !memcmp(&decl->macro, &d0->macro, sizeof decl->macro)) + return d0; for (int kind = TYstruct; kind <= TYunion; ++kind) { if (d0->t == Dtype && d0->ty->t == kind && decl->t == Dtype && decl->ty->t == kind && d0->ty->agg.fwd) { *(size_t *)&d0->ty->size = decl->ty->size; *(size_t *)&d0->ty->align = decl->ty->align; - *(bool *)&d0->ty->agg.fwd = 0; + *(bool *)&d0->ty->agg.fwd = decl->ty->agg.fwd; memcpy((void *)&d0->ty->agg.flds, &decl->ty->agg.flds, sizeof d0->ty->agg.flds); memcpy((void *)&d0->ty->agg.decls, &decl->ty->agg.decls, -- cgit v1.2.3