This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Hack in gcc/c-decl.c?


Hi,

Sorry, I didn't see that each identifier *is* a lang_identifier, that's 
a weird way to keep bindings. It's not that easy for someone new to GCC
to get around the code. What was the design decision behind that hack
(instead of something like:

struct tree_identifier {
  struct tree_common common;
  struct c_binding *binds[3];
  struct ht_identifier id;
})?


I see that make_node_stat allocates a large enough piece of
memory, but which function actually writes to 
I_SYMBOL_X(node)->Y_binding ? 


Thx.
  Domagoj


----- Original Message -----
From: "Mike Stump" <mrs@apple.com>
To: "Domagoj D" <domagoj@engineer.com>
Subject: Re: Hack in gcc/c-decl.c?
Date: Wed, 28 Dec 2005 23:30:22 -0800

> On Dec 28, 2005, at 8:49 PM, Domagoj D wrote:
> > Can anyone explain me the following gcc/c-decl.c code (4.0.2, seems to
> > be unchanged in 4.2)?
> 
> What part was unclear?
> 
> > #define I_SYMBOL_BINDING(node) \
> >   (((struct lang_identifier *)
> > IDENTIFIER_NODE_CHECK(node))->symbol_binding)
> 
> Yes, each identifier is a lang_identifier:
> 
>    /* sizeof (struct lang_identifier), so make_node () creates
>       identifier nodes long enough for the language-specific slots.  */
>    size_t identifier_size;
> 
> > Let's assume that new_decl is a VAR_DECL node. Than,
> > IDENTIFIER_NODE_CHECK(DECL_NAME(new_decl))
> >  = new_decl->decl->name, which is an IDENTIFIER_NODE. How is it
> > possible to cast it to (struct lang_identifier *) ??
> 
> Because that is the type of the pointer?
> 
> > [The worst thing is that it seems to work fine.]
> 
> As designed?



-- 
___________________________________________________
Play 100s of games for FREE! http://games.mail.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]