public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* DECL_NAME() yields ._69 for anonymous union parsed with g++
@ 2012-11-09  5:28 Peter Colberg
  2012-11-10 22:20 ` Peter Colberg
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Colberg @ 2012-11-09  5:28 UTC (permalink / raw)
  To: gcc-help

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: DECL_NAME() yields ._69 for anonymous union parsed with g++
  2012-11-09  5:28 DECL_NAME() yields ._69 for anonymous union parsed with g++ Peter Colberg
@ 2012-11-10 22:20 ` Peter Colberg
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Colberg @ 2012-11-10 22:20 UTC (permalink / raw)
  To: gcc-help

On Fri, Nov 09, 2012 at 12:28:03AM -0500, Peter Colberg wrote:
> 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?

Ok, I got it. The name format is defined as ANON_AGGRNAME_FORMAT.
The function responsible for naming anonymous structs/unions is
make_anon_name().

Use TYPE_ANONYMOUS_P() to check for anonymous structs/unions:

#include "cp/cp-tree.h"

RECORD_OR_UNION_CODE_P(TREE_CODE(node)) && TYPE_ANONYMOUS_P(node))


I hope my monologues on the GCC lists are useful to someone ;-).

Peter

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-11-10 22:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-09  5:28 DECL_NAME() yields ._69 for anonymous union parsed with g++ Peter Colberg
2012-11-10 22:20 ` Peter Colberg

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).