From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26039 invoked by alias); 29 Oct 2010 23:07:08 -0000 Received: (qmail 26027 invoked by uid 22791); 29 Oct 2010 23:07:08 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mail-iw0-f175.google.com (HELO mail-iw0-f175.google.com) (209.85.214.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 29 Oct 2010 23:07:02 +0000 Received: by iwn42 with SMTP id 42so3157735iwn.20 for ; Fri, 29 Oct 2010 16:07:01 -0700 (PDT) MIME-Version: 1.0 Received: by 10.42.214.137 with SMTP id ha9mr416716icb.279.1288393620943; Fri, 29 Oct 2010 16:07:00 -0700 (PDT) Received: by 10.231.144.197 with HTTP; Fri, 29 Oct 2010 16:07:00 -0700 (PDT) In-Reply-To: <37BDB13D-DADF-4B6B-81B7-E6624BDEFA74@sandoe-acoustics.co.uk> References: <5AEA56D9-052C-4FE7-B8E0-D78BDFCD3C57@sandoe-acoustics.co.uk> <37BDB13D-DADF-4B6B-81B7-E6624BDEFA74@sandoe-acoustics.co.uk> Date: Sat, 30 Oct 2010 07:20:00 -0000 Message-ID: Subject: Re: [Patch, RFC, c*, ObjC* ] make the translation unit decl avail. via a lang hook From: Richard Guenther To: IainS Cc: GCC Patches , Mike Stump , Nicola Pero Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2010-10/txt/msg02606.txt.bz2 On Fri, Oct 29, 2010 at 5:57 PM, IainS w= rote: > Hi Richard, > > On 29 Oct 2010, at 16:28, Richard Guenther wrote: > >> On Fri, Oct 29, 2010 at 3:44 PM, IainS >> wrote: >>> >>> given that my current understanding is: >>> (a) we should make vars file-scope by setting DECL_CONTEXT =3D translat= ion >>> 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. =A0Note 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). Well, I would argue that builtins don't really have a TU unless they are re-declared from a header. > [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 =A0(called current_translation_unit_decl) > - but that means defining it also in lto which seemed unnecessary. Why in LTO? What does LTO have to do with ObjC? >> 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, =A0ObjC* must use the t_u_d created in c* - since they are > sharing spaces. Well, ok. > 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). Maybe I am missing something fundamental. Why's this suddenly about builtins? Richard. > Iain > >> Richard. > > >