Next: Namespaces, Up: C and C++ Trees
In C++, an array type is not qualified; rather the type of the array
elements is qualified. This situation is reflected in the intermediate
representation. The macros described here will always examine the
qualification of the underlying element type when applied to an array
type. (If the element type is itself an array, then the recursion
continues until a non-array type is found, and the qualification of this
type is examined.) So, for example, CP_TYPE_CONST_P will hold of
the type const int ()[7], denoting an array of seven ints.
The following functions and macros deal with cv-qualification of types:
CP_TYPE_QUALSTYPE_UNQUALIFIED if no qualifiers have been
applied. The TYPE_QUAL_CONST bit is set if the type is
const-qualified. The TYPE_QUAL_VOLATILE bit is set if the
type is volatile-qualified. The TYPE_QUAL_RESTRICT bit is
set if the type is restrict-qualified.
CP_TYPE_CONST_Pconst-qualified.
CP_TYPE_VOLATILE_Pvolatile-qualified.
CP_TYPE_RESTRICT_Prestrict-qualified.
CP_TYPE_CONST_NON_VOLATILE_Pconst-qualified, but
not volatile-qualified; other cv-qualifiers are ignored as
well: only the const-ness is tested.
A few other macros and functions are usable with all types:
TYPE_SIZEINTEGER_CST. For an incomplete type, TYPE_SIZE will be
NULL_TREE.
TYPE_ALIGNint.
TYPE_NAMETYPE_DECL) for
the type. (Note this macro does not return an
IDENTIFIER_NODE, as you might expect, given its name!) You can
look at the DECL_NAME of the TYPE_DECL to obtain the
actual name of the type. The TYPE_NAME will be NULL_TREE
for a type that is not a built-in type, the result of a typedef, or a
named class type.
CP_INTEGRAL_TYPEARITHMETIC_TYPE_PCLASS_TYPE_PTYPE_BUILT_INTYPE_PTRMEM_PTYPE_PTR_PTYPE_PTRFN_PTYPE_PTROB_Pvoid *. You
may use TYPE_PTROBV_P to test for a pointer to object type as
well as void *.
The table below describes types specific to C and C++ as well as language-dependent info about GENERIC types.
POINTER_TYPETREE_TYPE
is a pointer to data member type, then TYPE_PTRMEM_P will hold.
For a pointer to data member type of the form `T X::*',
TYPE_PTRMEM_CLASS_TYPE will be the type X, while
TYPE_PTRMEM_POINTED_TO_TYPE will be the type T.
RECORD_TYPEstruct and class types in C and C++. If
TYPE_PTRMEMFUNC_P holds, then this type is a pointer-to-member
type. In that case, the TYPE_PTRMEMFUNC_FN_TYPE is a
POINTER_TYPE pointing to a METHOD_TYPE. The
METHOD_TYPE is the type of a function pointed to by the
pointer-to-member function. If TYPE_PTRMEMFUNC_P does not hold,
this type is a class type. For more information, see see Classes.
UNKNOWN_TYPETYPENAME_TYPEtypename T::A. The
TYPE_CONTEXT is T; the TYPE_NAME is an
IDENTIFIER_NODE for A. If the type is specified via a
template-id, then TYPENAME_TYPE_FULLNAME yields a
TEMPLATE_ID_EXPR. The TREE_TYPE is non-NULL if the
node is implicitly generated in support for the implicit typename
extension; in which case the TREE_TYPE is a type node for the
base-class.
TYPEOF_TYPE__typeof__ extension. The
TYPE_FIELDS is the expression the type of which is being
represented.