DECL_NAME() yields ._69 for anonymous union parsed with g++

Peter Colberg peter@colberg.org
Fri Nov 9 05:28:00 GMT 2012


Hi,

I am analysing the AST of the following code (of GCC):

  struct ssa_use_operand_d {
    struct ssa_use_operand_d *prev;
    struct ssa_use_operand_d *next;
    union {
       gimple stmt;
       tree ssa_name;
    } loc;
     tree *use;
  };

DECL_NAME(TYPE_NAME(t)) of the union type node should equal
NULL_TREE, since it is an unnamed entity. However, if I parse
the above code using g++, the returned identifier is "._69".

Converting the AST back to C code using the gcc-lua plugin, this yields

  union ._69 {
    gimple stmt;
    tree ssa_name;
  };
  struct ssa_use_operand_d {
    struct ssa_use_operand_d *prev;
    struct ssa_use_operand_d *next;
    union ._69 loc;
    tree *use;
  };

Why does g++ assign an identifier to an unnamed (artificial) TYPE_DECL?

How can one differentiate between a named and an unnamed union, if
the TYPE_DECL node has an (user- or compiler-generated) identifier
in both cases?

Thanks,
Peter



More information about the Gcc-help mailing list