Next: Attributes, Previous: Functions, Up: Trees
This section covers the various kinds of declarations that appear in the
internal representation, except for declarations of functions
(represented by FUNCTION_DECL
nodes), which are described in
Functions.
Some macros can be used with any kind of declaration. These include:
DECL_NAME
IDENTIFIER_NODE
giving the name of the
entity.
TREE_TYPE
TREE_FILENAME
char*
. For an entity declared implicitly by the
compiler (like __builtin_memcpy
), this will be the string
"<internal>"
.
TREE_LINENO
int
.
DECL_ARTIFICIAL
TYPE_DECL
implicitly
generated for a class type. Recall that in C++ code like:
struct S {};
is roughly equivalent to C code like:
struct S {}; typedef struct S S;
The implicitly generated typedef
declaration is represented by a
TYPE_DECL
for which DECL_ARTIFICIAL
holds.
DECL_NAMESPACE_SCOPE_P
DECL_CLASS_SCOPE_P
DECL_FUNCTION_SCOPE_P
The various kinds of declarations include:
LABEL_DECL
CONST_DECL
DECL_INITIAL
which will be an
INTEGER_CST
with the same type as the TREE_TYPE
of the
CONST_DECL
, i.e., an ENUMERAL_TYPE
.
RESULT_DECL
RESULT_DECL
, that indicates that the value should
be returned, via bitwise copy, by the function. You can use
DECL_SIZE
and DECL_ALIGN
on a RESULT_DECL
, just as
with a VAR_DECL
.
TYPE_DECL
typedef
declarations. The TREE_TYPE
is the type declared to have the name given by DECL_NAME
. In
some cases, there is no associated name.
VAR_DECL
DECL_SIZE
and DECL_ALIGN
are
analogous to TYPE_SIZE
and TYPE_ALIGN
. For a declaration,
you should always use the DECL_SIZE
and DECL_ALIGN
rather
than the TYPE_SIZE
and TYPE_ALIGN
given by the
TREE_TYPE
, since special attributes may have been applied to the
variable to give it a particular size and alignment. You may use the
predicates DECL_THIS_STATIC
or DECL_THIS_EXTERN
to test
whether the storage class specifiers static
or extern
were
used to declare a variable.
If this variable is initialized (but does not require a constructor),
the DECL_INITIAL
will be an expression for the initializer. The
initializer should be evaluated, and a bitwise copy into the variable
performed. If the DECL_INITIAL
is the error_mark_node
,
there is an initializer, but it is given by an explicit statement later
in the code; no bitwise copy is required.
GCC provides an extension that allows either automatic variables, or
global variables, to be placed in particular registers. This extension
is being used for a particular VAR_DECL
if DECL_REGISTER
holds for the VAR_DECL
, and if DECL_ASSEMBLER_NAME
is not
equal to DECL_NAME
. In that case, DECL_ASSEMBLER_NAME
is
the name of the register into which the variable will be placed.
PARM_DECL
VAR_DECL
nodes. These nodes only appear in the
DECL_ARGUMENTS
for a FUNCTION_DECL
.
The DECL_ARG_TYPE
for a PARM_DECL
is the type that will
actually be used when a value is passed to this function. It may be a
wider type than the TREE_TYPE
of the parameter; for example, the
ordinary type might be short
while the DECL_ARG_TYPE
is
int
.
FIELD_DECL
DECL_SIZE
and
DECL_ALIGN
behave as for VAR_DECL
nodes. The
DECL_FIELD_BITPOS
gives the first bit used for this field, as an
INTEGER_CST
. These values are indexed from zero, where zero
indicates the first bit in the object.
If DECL_C_BIT_FIELD
holds, this field is a bit-field.
NAMESPACE_DECL
TEMPLATE_DECL
DECL_TEMPLATE_SPECIALIZATIONS
are a
TREE_LIST
. The TREE_VALUE
of each node in the list is a
TEMPLATE_DECL
s or FUNCTION_DECL
s representing
specializations (including instantiations) of this template. Back ends
can safely ignore TEMPLATE_DECL
s, but should examine
FUNCTION_DECL
nodes on the specializations list just as they
would ordinary FUNCTION_DECL
nodes.
For a class template, the DECL_TEMPLATE_INSTANTIATIONS
list
contains the instantiations. The TREE_VALUE
of each node is an
instantiation of the class. The DECL_TEMPLATE_SPECIALIZATIONS
contains partial specializations of the class.
USING_DECL