This is the mail archive of the
mailing list for the GCC project.
Re: Candidate fix for PR 15007
Geoff Keating <email@example.com> writes:
> Zack Weinberg <firstname.lastname@example.org> writes:
>> It seems to me that the most straightforward way to fix PR 15007 is to
>> avoid generating a TRANSLATION_UNIT_DECL at all until we're done
>> parsing the entire translation unit. This mirrors what is done with
>> BLOCK nodes - we create them only when the scope is popped.
>> Fortunately, DECL_FILE_SCOPE_P can already handle this, so the change
>> is limited to c-decl.c.
> This isn't exactly what your patch does. If I'm reading it right, it
> defers creating the TRANSLATION_UNIT_DECL until the first global
> declaration is seen. The approach you described would have been
> trouble, but the one actually implemented looks like it would work.
Hein? It's created in pop_scope when the file scope is popped. Which
happens exactly when the translation unit is complete. We then go
back and fix up DECL_CONTEXT for everything in that scope. This works
because everything that checks DECL_CONTEXT accepts 0 as meaning file
scope. Is there something I'm missing?