Waldek Hebisch wrote:
Static variables must be initialized only once, even if they're local (otherwise they'd lose their values when the containing routine is called again which would defeat much of their purpose). I see two ways of doing it:
- Initialize them from the module/program constructor. That's what I'm doing now. The problem is that we have to violate the scoping internally, and apparently the current way is not correct since the AIX linker probably considers the variable to be initialized as different from the actual local variable and so runs into unresolved references.
AFAICS with qualified identifiers we can move static variables to global scope (mangle name and set DECL_CONTEXT to 0), which should avoid the problem.
I've tried this when I did this initially. According to a note of mine, just setting DECL_CONTEXT to NULL caused some problems (I don't remember exactly which at the moment), but I think I'll have to investigate them again and try to fix them if possible. (Maybe it's because such a declaration shouldn't be in the list that the backend retrieves via getdecls() locally, rather in the global list, but that's just a guess for now ...)
Mangling the (linker) name is also an issue, but even without QI this shouldn't be a big deal (get_unique_identifier or so, since this name is only used internally, unless an explicit name attribute is given, in which case the issue doesn't arise). I'll also apply your QI patches, of course, but right now I need an AIX fix quickly.
Frank