Hi,

Can anyone explain me the following gcc/c-decl.c code (4.0.2, seems to 
be unchanged in 4.2)?

...

#define I_SYMBOL_BINDING(node) \
  (((struct lang_identifier *)
IDENTIFIER_NODE_CHECK(node))->symbol_binding)

...

static void
warn_if_shadowing (tree new_decl)
{
  struct c_binding *b;
  ...
  /* Is anything being shadowed?  Invisible decls do not count.  */
  for (b = I_SYMBOL_BINDING (DECL_NAME (new_decl)); b; b = b->shadowed)
    if (b->decl && b->decl != new_decl && !b->invisible)
    ...
  }
  ...
}

...

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 *) ??

[The worst thing is that it seems to work fine.]



Just to recap:
----------------------------------------------------------------------
tree.h:
struct tree_identifier GTY(())
{
  struct tree_common ommon;
  struct ht_identifier id;
};

symtab.h:
struct ht_identifier GTY(())
{
  const unsigned char *str;
  unsigned int len;
  unsigned int hash_value;
};

c-decl.c:
struct c_binding GTY((chain_next ("%h.prev")))
{
  tree decl;            /* the decl bound */
  tree type;            /* the type in this scope */
  tree id;            /* the identifier it's bound to */
  struct c_binding *prev;    /* the previous decl in this scope */
  struct c_binding *shadowed;    /* the innermost decl shadowed by this one */
  unsigned int depth : 28;      /* depth of this scope */
  BOOL_BITFIELD invisible : 1;  /* normal lookup should ignore this
binding */
  BOOL_BITFIELD nested : 1;     /* do not set DECL_CONTEXT when popping */
  BOOL_BITFIELD inner_comp : 1; /* incomplete array completed in inner
scope */
  /* one free bit */
};

c-decl.c:
struct lang_identifier GTY(())
{
  struct c_common_identifier common_id;
  struct c_binding *symbol_binding; /* vars, funcs, constants, typedefs */
  struct c_binding *tag_binding;    /* struct/union/enum tags */
  struct c_binding *label_binding;  /* labels */
};
----------------------------------------------------------------------

Thx! Regards,
        Domagoj


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

Reply via email to