| git.druid.rocks | index | druid520 | nscc | test/ | t51_gvar_linkage_upgrade.nsc |
test/t51_gvar_linkage_upgrade.nsc
/* regression test, gvar half of the same jscope2 bug the include test
* covers for functions: a bare (non-global, no-initializer)
* reference to a name, followed later by its real `global`
* definition, must upgrade linkage to global -- previously the
* upgrade only ever happened in the has-an-initializer case, so a
* bare-reference-then-tentative-global-definition (exactly what a
* shared header full of plain declarations plus one file's own
* `global` definition produces) silently stayed 'local' forever. */
u64 counter;
void bump(void) {
counter = counter + (u64)1;
}
global u64 counter;
global i32 main(void) {
bump();
bump();
bump();
return (i32)counter;
}