diff options
author | Michael Forney <mforney@mforney.org> | 2019-05-15 23:53:12 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-05-16 00:33:57 -0700 |
commit | 73e7c145e0c5d983cec3be18240851324b818d9f (patch) | |
tree | 274d82e084a5382248ec857864398c796fd1582d | |
parent | a813137236b2c51de81dff3a869887f1b91cebee (diff) | |
download | cproc-73e7c145e0c5d983cec3be18240851324b818d9f.tar.xz |
decl: extern storage class with initializer is still a definition
-rw-r--r-- | decl.c | 6 | ||||
-rw-r--r-- | test/extern-initializer.c | 1 | ||||
-rw-r--r-- | test/extern-initializer.qbe | 1 |
3 files changed, 4 insertions, 4 deletions
@@ -917,9 +917,7 @@ decl(struct scope *s, struct func *f) } else { init = NULL; } - if (sc & SCEXTERN) - break; - if (init || f) { + if (init || d->linkage == LINKNONE) { if (d->linkage != LINKNONE || sc & SCSTATIC) emitdata(d, init); else @@ -929,7 +927,7 @@ decl(struct scope *s, struct func *f) d->tentative = false; listremove(&d->link); } - } else if (!d->defined && !d->tentative) { + } else if (!(sc & SCEXTERN) && !d->defined && !d->tentative) { d->tentative = true; listinsert(tentativedefns.prev, &d->link); } diff --git a/test/extern-initializer.c b/test/extern-initializer.c new file mode 100644 index 0000000..a17c036 --- /dev/null +++ b/test/extern-initializer.c @@ -0,0 +1 @@ +extern int x = 1; diff --git a/test/extern-initializer.qbe b/test/extern-initializer.qbe new file mode 100644 index 0000000..9814f66 --- /dev/null +++ b/test/extern-initializer.qbe @@ -0,0 +1 @@ +export data $x = align 4 { w 1, } |