Steven commented:
Maybe there should be a macro HAS_FILE_SCOPE in tree.h??
As I was thinking about this a little further I was wondering why
DECL_CONTEXT should ever be NULL after this patch. Why not just
_always_ put a TRANSLATION_UNIT_DECL in DECL_CONTEXT if the entity is
global, even if gcc is not doing intermodule stuff.
I think I decided you don't want to do that if the declaration isn't
static, and there was some good reason for it, but don't remember
exactly. Feel free to try it and tell me how it turns out :-).
I haven't yet found a need for it. I think file scope (or,
technically, translation unit scope) is a language-specific
concept---I can certainly imagine languages where it is
meaningless---and so it probably shouldn't appear in the middle-end.
Usually, you want TREE_PUBLIC or TREE_STATIC or DECL_EXTERNAL
instead.
Well, we should define some semantics for this; after all, trees
should
be language-independent for tree-ssa.
I agree that we should define the meaning of TRANSLATION_UNIT_DECL, at
least in some vague way ("like NAMESPACE_DECL, but doesn't have a
name"), I just don't think that we need the particular predicate you
suggested. Could you give an example of how it would be used?