mirror of
https://github.com/frida/tinycc
synced 2024-11-24 08:39:37 +03:00
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.
This commit is contained in:
parent
5732a1882e
commit
94ac9f2b49
3
tccgen.c
3
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 */
|
||||
|
@ -1752,6 +1752,8 @@ arrtype2 sinit22 = {5,6,7};
|
||||
int sinit23[2] = { "astring" ? sizeof("astring") : -1,
|
||||
&sinit23 ? 42 : -1 };
|
||||
|
||||
extern int external_inited = 42;
|
||||
|
||||
void init_test(void)
|
||||
{
|
||||
int linit1 = 2;
|
||||
|
Loading…
Reference in New Issue
Block a user