This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Tree
On 4 July 2011 15:28, konica sarker wrote:
> "A tree is a pointer type, but the object to which it points may be of
> a variety of types"
>
> suppose i have a tree t;
> can you help me, how to identify the object type of the tree?
>From http://gcc.gnu.org/onlinedocs/gccint/Tree-overview.html
"You can tell what kind of node a particular tree is by using the
TREE_CODE macro."
> what does the function TREE_TYPE() do?
>From http://gcc.gnu.org/onlinedocs/gccint/Macros-and-Functions.html
"Many trees store the type of an expression or declaration in this field."
And from gcc/tree.h:
/* In all nodes that are expressions, this is the data type of the expression.
In POINTER_TYPE nodes, this is the type that the pointer points to.
In ARRAY_TYPE nodes, this is the type of the elements.
In VECTOR_TYPE nodes, this is the type of the elements. */
#define TREE_TYPE(NODE) __extension__ \
(*({__typeof (NODE) const __t = CONTAINS_STRUCT_CHECK (NODE, TS_TYPED); \
&__t->typed.type; }))