diff options
-rw-r--r-- | cc.h | 10 | ||||
-rw-r--r-- | decl.c | 18 | ||||
-rw-r--r-- | util.c | 1 |
3 files changed, 12 insertions, 17 deletions
@@ -255,13 +255,13 @@ struct decl { struct type *type; enum typequal qual; struct value *value; + _Bool defined; - /* objects and functions */ - struct list link; - int align; /* may be more strict than type requires */ - _Bool tentative, defined; + /* link in list of tentative object definitions */ + struct list tentative; + /* alignment of object storage (may be stricter than type requires) */ + int align; - /* built-ins */ enum builtinkind builtin; }; @@ -65,14 +65,11 @@ mkdecl(enum declkind k, struct type *t, enum typequal tq, enum linkage linkage) struct decl *d; d = xmalloc(sizeof(*d)); + memset(d, 0, sizeof(*d)); d->kind = k; d->linkage = linkage; d->type = t; d->qual = tq; - d->tentative = false; - d->defined = false; - d->align = 0; - d->value = NULL; return d; } @@ -971,13 +968,10 @@ decl(struct scope *s, struct func *f) else funcinit(f, d, init); d->defined = true; - if (d->tentative) { - d->tentative = false; - listremove(&d->link); - } - } else if (!(sc & SCEXTERN) && !d->defined && !d->tentative) { - d->tentative = true; - listinsert(tentativedefns.prev, &d->link); + if (d->tentative.next) + listremove(&d->tentative); + } else if (!(sc & SCEXTERN) && !d->defined && !d->tentative.next) { + listinsert(tentativedefns.prev, &d->tentative); } break; case DECLFUNC: @@ -1053,5 +1047,5 @@ emittentativedefns(void) struct list *l; for (l = tentativedefns.next; l != &tentativedefns; l = l->next) - emitdata(listelement(l, struct decl, link), NULL); + emitdata(listelement(l, struct decl, tentative), NULL); } @@ -130,4 +130,5 @@ listremove(struct list *list) { list->next->prev = list->prev; list->prev->next = list->next; + list->next = list->prev = NULL; } |