From: Daniel Berlin <dberlin@dberlin.org>
To: Stephen Biggs <xyzzy@hotpop.com>
Cc: GCC list <gcc@gcc.gnu.org>
Subject: Re: Local binding DECLs
Date: Mon, 12 May 2003 07:30:00 -0000 [thread overview]
Message-ID: <91E73B7B-844B-11D7-87A1-000A95A34564@dberlin.org> (raw)
In-Reply-To: <1052721885.2480.8.camel@steve.softier.local>
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
next prev parent reply other threads:[~2003-05-12 7:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-08 11:40 Stephen Biggs
2003-05-08 22:04 ` Richard Henderson
2003-05-11 7:03 ` Stephen Biggs
2003-05-12 1:15 ` Richard Henderson
2003-05-12 6:41 ` Stephen Biggs
2003-05-12 7:30 ` Daniel Berlin [this message]
2003-05-12 10:32 ` Stephen Biggs
2003-05-12 12:54 ` Stephen Biggs
2003-05-12 17:15 ` Richard Henderson
[not found] ` <jm1xz33cu5.fsf@desire.geoffk.org>
2003-05-13 8:45 ` Stephen Biggs
2003-05-14 18:31 ` Geoff Keating
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=91E73B7B-844B-11D7-87A1-000A95A34564@dberlin.org \
--to=dberlin@dberlin.org \
--cc=gcc@gcc.gnu.org \
--cc=xyzzy@hotpop.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).