aboutsummaryrefslogtreecommitdiff
path: root/tccgen.c
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2017-05-07 08:10:06 +0200
committerMichael Matz <matz@suse.de>2017-05-07 08:10:06 +0200
commit94ac9f2b4952fbd77bfdf39e753fcbca3e472883 (patch)
tree64ae33f596c660b2cbf028a006e2ab6a9251773a /tccgen.c
parent5732a1882e3a0fa74e766049f71ec3b7c51808f3 (diff)
downloadtinycc-94ac9f2b4952fbd77bfdf39e753fcbca3e472883.tar.gz
tinycc-94ac9f2b4952fbd77bfdf39e753fcbca3e472883.tar.bz2
Accept extern initialized file-scope variables
'extern int i = 42;' at file scope (but not in function scope!) is allowed and is a proper definition, even though questionable style; some compilers warn about this.
Diffstat (limited to 'tccgen.c')
-rw-r--r--tccgen.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/tccgen.c b/tccgen.c
index 1fe5e93..424c4e0 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -6955,7 +6955,8 @@ found:
has_init = (tok == '=');
if (has_init && (type.t & VT_VLA))
tcc_error("variable length array cannot be initialized");
- if ((type.t & VT_EXTERN) || ((type.t & VT_BTYPE) == VT_FUNC) ||
+ if (((type.t & VT_EXTERN) && (!has_init || l != VT_CONST)) ||
+ ((type.t & VT_BTYPE) == VT_FUNC) ||
((type.t & VT_ARRAY) && (type.t & VT_STATIC) &&
!has_init && l == VT_CONST && type.ref->c < 0)) {
/* external variable or function */