aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cc.h10
-rw-r--r--decl.c18
-rw-r--r--util.c1
3 files changed, 12 insertions, 17 deletions
diff --git a/cc.h b/cc.h
index 4054dcd..47a2931 100644
--- a/cc.h
+++ b/cc.h
@@ -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;
};
diff --git a/decl.c b/decl.c
index 9013a09..26e9851 100644
--- a/decl.c
+++ b/decl.c
@@ -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);
}
diff --git a/util.c b/util.c
index 1e44194..1229f2c 100644
--- a/util.c
+++ b/util.c
@@ -130,4 +130,5 @@ listremove(struct list *list)
{
list->next->prev = list->prev;
list->prev->next = list->next;
+ list->next = list->prev = NULL;
}