diff options
Diffstat (limited to 'bootstrap/env.c')
| -rw-r--r-- | bootstrap/env.c | 8 |
1 files changed, 7 insertions, 1 deletions
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, |