From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3302 invoked by alias); 12 May 2003 07:30:17 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 3234 invoked from network); 12 May 2003 07:30:16 -0000 Received: from unknown (HELO dberlin.org) (69.3.5.6) by sources.redhat.com with SMTP; 12 May 2003 07:30:16 -0000 Received: from [192.168.1.3] (account dberlin HELO dberlin.org) by dberlin.org (CommuniGate Pro SMTP 4.1b6) with ESMTP-TLS id 3951243; Mon, 12 May 2003 03:30:15 -0400 Date: Mon, 12 May 2003 07:30:00 -0000 Subject: Re: Local binding DECLs Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) Cc: GCC list To: Stephen Biggs From: Daniel Berlin In-Reply-To: <1052721885.2480.8.camel@steve.softier.local> Message-Id: <91E73B7B-844B-11D7-87A1-000A95A34564@dberlin.org> Content-Transfer-Encoding: 7bit X-SW-Source: 2003-05/txt/msg01090.txt.bz2 On Monday, May 12, 2003, at 02:44 AM, Stephen Biggs wrote: > On Mon, 2003-05-12 at 04:13, Richard Henderson wrote: >> On Sun, May 11, 2003 at 10:04:20AM +0300, Stephen Biggs wrote: >>> Ok... is there ANY way to find out if the FUNCTION_DECL I am handed >>> at >>> any time (preferably in ENCODE_SECTION) is declared in a function >>> block >>> as opposed to globally? >> >> *Declared*? I.e. to distinguish >> >> extern void foo(); >> void bar() { foo(); } >> >> from >> >> void bar() { >> extern void foo(); >> foo(); >> } >> >> Absolutely not. That question doesn't even make sense. >> >> >> r~ >> > Sure it does, if you have, for example: > > void bar() { > static void foo(); > foo(); > } > > void bar1() { > static int foo(); > foo(); > } > > void bar2() { > static int foo(int); > int a = foo(3); > } > foo() {} > > This compiles. > > I see nothing that gives me the ability to know that any particular > DECL > is declared inside a particular function. > Errr, won't DECL_CONTEXT do what you want? From tree.h: /* For FIELD_DECLs, this is the RECORD_TYPE, UNION_TYPE, or QUAL_UNION_TYPE node that the field is a member of. For VAR_DECL, PARM_DECL, FUNCTION_DECL, LABEL_DECL, and CONST_DECL nodes, this points to either the FUNCTION_DECL for the containing function, the RECORD_TYPE or UNION_TYPE for the containing type, or NULL_TREE if the given decl has "file scope". */ #define DECL_CONTEXT(NODE) (DECL_CHECK (NODE)->decl.context) DECL_CONTEXT on a contained function_decl should give you the containing function_decl (or NULL_TREE if it's not contained/is file scope), as the comment says. Does it not work? I haven't really been following till now. --Dan