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: Getting a tree node for a field of a variable


Hi,

Look in tree.def.

Given the RECORD_TYPE node, walk down TYPE_FIELDS looking for the
FIELD_DECL that you want.

To assign to a field use a COMPONENT_REF.

Is it possible to write a short example how a it could be referred the tree of variable field? Let's say that we have somewhere defined the following source code:

--- code ---
typedef struct MyType
{
 int field1;
 int field2;
}

MyType *var;
--- code ---

What I want is to get the tree node of "var->field1". For now I can
get the tree of the "var" declaration with the code bellow.

tree var_decl = lookup_name(get_identifier("var"));

And I suppose that, having "var_decl" I can get a tree to the "field1"
field of "var". Is there any function e.g. lookup_decl_field that does
it?

Ferad Zyulkyarov


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