This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, RFC, c*, ObjC* ] make the translation unit decl avail. via a lang hook
Hi Richard,
On 29 Oct 2010, at 16:28, Richard Guenther wrote:
On Fri, Oct 29, 2010 at 3:44 PM, IainS <developer@sandoe-acoustics.co.uk
> wrote:
given that my current understanding is:
(a) we should make vars file-scope by setting DECL_CONTEXT =
translation
unit decl
(b) there should only be one translation unit decl per TU
(c) at present none of the FEs export the t_u_d where other parts
of the
machinery can see it.
would the following patch be appropriate?
(it can be extended to fortran and java, I believe, fairly easily).
Sounds like a hack. Note that frontends might end up with multiple
TUs (for example for things in fortran modules).
One would assume that a built-in that wishes to push an item to the
'file scope' would still use 'current_translation_unit_decl'.
(to attach the decl to the 'file scope' of the current module).
[and I guess the name mangling must take care of different module
ordering in different fortran source files?]
It's a hack because
it's a frontend hook that is only used by the frontend (which means
a single global variable does do it as well,
OK, I had a global originally (called current_translation_unit_decl)
- but that means defining it also in lto which seemed unnecessary.
like other FEs do it
none of the FEs make the t_u_d available outside the file in which
it's created.
and, AFAICT, ObjC* must use the t_u_d created in c* - since they are
sharing spaces.
If this seems reasonable
I can re-do the patch as I had it originally - with a global.
(or if I'm missing something fundamental, a pointer would be
appreciated).
Iain
Richard.