aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cc.h7
-rw-r--r--decl.c23
2 files changed, 15 insertions, 15 deletions
diff --git a/cc.h b/cc.h
index 97d3e66..4eb2c63 100644
--- a/cc.h
+++ b/cc.h
@@ -278,11 +278,11 @@ struct decl {
struct value *value;
char *asmname;
bool defined;
+ bool tentative;
+ struct decl *next;
union {
struct {
- /* link in list of tentative object definitions */
- struct list tentative;
/* alignment of object storage (may be stricter than type requires) */
int align;
} obj;
@@ -290,9 +290,6 @@ struct decl {
/* the function might have an "inline definition" (C11 6.7.4p7) */
bool inlinedefn;
} func;
- struct {
- struct decl *next;
- } enumconst;
enum builtinkind builtin;
} u;
};
diff --git a/decl.c b/decl.c
index 9b7f664..eb9217b 100644
--- a/decl.c
+++ b/decl.c
@@ -8,7 +8,7 @@
#include "util.h"
#include "cc.h"
-static struct list tentativedefns = {&tentativedefns, &tentativedefns};
+static struct decl *tentativedefns, **tentativedefnsend = &tentativedefns;
struct qualtype {
struct type *type;
@@ -273,7 +273,7 @@ tagspec(struct scope *s)
}
d = mkdecl(DECLCONST, et, QUALNONE, LINKNONE);
d->value = mkintconst(value);
- d->u.enumconst.next = enumconsts;
+ d->next = enumconsts;
enumconsts = d;
if (et->u.basic.issigned && value >= 1ull << 63) {
if (-value > min)
@@ -299,7 +299,7 @@ tagspec(struct scope *s)
if (i == LEN(inttypes))
error(&tok.loc, "no integer type can represent all enumerator values");
t->base = et;
- for (d = enumconsts; d; d = d->u.enumconst.next)
+ for (d = enumconsts; d; d = d->next)
d->type = t;
}
t->size = t->base->size;
@@ -1073,8 +1073,11 @@ decl(struct scope *s, struct func *f)
init = parseinit(s, d->type);
hasinit = true;
} else if (d->linkage != LINKNONE) {
- if (!(sc & SCEXTERN) && !d->defined && !d->u.obj.tentative.next)
- listinsert(tentativedefns.prev, &d->u.obj.tentative);
+ if (!(sc & SCEXTERN) && !d->defined && !d->tentative) {
+ d->tentative = true;
+ *tentativedefnsend = d;
+ tentativedefnsend = &d->next;
+ }
break;
}
if (d->linkage != LINKNONE || sc & SCSTATIC)
@@ -1082,8 +1085,6 @@ decl(struct scope *s, struct func *f)
else
funcinit(f, d, init, hasinit);
d->defined = true;
- if (d->u.obj.tentative.next)
- listremove(&d->u.obj.tentative);
break;
case DECLFUNC:
if (align)
@@ -1157,8 +1158,10 @@ stringdecl(struct expr *expr)
void
emittentativedefns(void)
{
- struct list *l;
+ struct decl *d;
- for (l = tentativedefns.next; l != &tentativedefns; l = l->next)
- emitdata(listelement(l, struct decl, u.obj.tentative), NULL);
+ for (d = tentativedefns; d; d = d->next) {
+ if (!d->defined)
+ emitdata(d, NULL);
+ }
}