gccint: Working with declarations
1
1 11.4.1 Working with declarations
1 --------------------------------
1
1 Some macros can be used with any kind of declaration. These include:
1 'DECL_NAME'
1 This macro returns an 'IDENTIFIER_NODE' giving the name of the
1 entity.
1
1 'TREE_TYPE'
1 This macro returns the type of the entity declared.
1
1 'EXPR_FILENAME'
1 This macro returns the name of the file in which the entity was
1 declared, as a 'char*'. For an entity declared implicitly by the
1 compiler (like '__builtin_memcpy'), this will be the string
1 '"<internal>"'.
1
1 'EXPR_LINENO'
1 This macro returns the line number at which the entity was
1 declared, as an 'int'.
1
1 'DECL_ARTIFICIAL'
1 This predicate holds if the declaration was implicitly generated by
1 the compiler. For example, this predicate will hold of an
1 implicitly declared member function, or of the 'TYPE_DECL'
1 implicitly generated for a class type. Recall that in C++ code
1 like:
1 struct S {};
1 is roughly equivalent to C code like:
1 struct S {};
1 typedef struct S S;
1 The implicitly generated 'typedef' declaration is represented by a
1 'TYPE_DECL' for which 'DECL_ARTIFICIAL' holds.
1
1 The various kinds of declarations include:
1 'LABEL_DECL'
1 These nodes are used to represent labels in function bodies. For
1 more information, see ⇒Functions. These nodes only appear
1 in block scopes.
1
1 'CONST_DECL'
1 These nodes are used to represent enumeration constants. The value
1 of the constant is given by 'DECL_INITIAL' which will be an
1 'INTEGER_CST' with the same type as the 'TREE_TYPE' of the
1 'CONST_DECL', i.e., an 'ENUMERAL_TYPE'.
1
1 'RESULT_DECL'
1 These nodes represent the value returned by a function. When a
1 value is assigned to a 'RESULT_DECL', that indicates that the value
1 should be returned, via bitwise copy, by the function. You can use
1 'DECL_SIZE' and 'DECL_ALIGN' on a 'RESULT_DECL', just as with a
1 'VAR_DECL'.
1
1 'TYPE_DECL'
1 These nodes represent 'typedef' declarations. The 'TREE_TYPE' is
1 the type declared to have the name given by 'DECL_NAME'. In some
1 cases, there is no associated name.
1
1 'VAR_DECL'
1 These nodes represent variables with namespace or block scope, as
1 well as static data members. The 'DECL_SIZE' and 'DECL_ALIGN' are
1 analogous to 'TYPE_SIZE' and 'TYPE_ALIGN'. For a declaration, you
1 should always use the 'DECL_SIZE' and 'DECL_ALIGN' rather than the
1 'TYPE_SIZE' and 'TYPE_ALIGN' given by the 'TREE_TYPE', since
1 special attributes may have been applied to the variable to give it
1 a particular size and alignment. You may use the predicates
1 'DECL_THIS_STATIC' or 'DECL_THIS_EXTERN' to test whether the
1 storage class specifiers 'static' or 'extern' were used to declare
1 a variable.
1
1 If this variable is initialized (but does not require a
1 constructor), the 'DECL_INITIAL' will be an expression for the
1 initializer. The initializer should be evaluated, and a bitwise
1 copy into the variable performed. If the 'DECL_INITIAL' is the
1 'error_mark_node', there is an initializer, but it is given by an
1 explicit statement later in the code; no bitwise copy is required.
1
1 GCC provides an extension that allows either automatic variables,
1 or global variables, to be placed in particular registers. This
1 extension is being used for a particular 'VAR_DECL' if
1 'DECL_REGISTER' holds for the 'VAR_DECL', and if
1 'DECL_ASSEMBLER_NAME' is not equal to 'DECL_NAME'. In that case,
1 'DECL_ASSEMBLER_NAME' is the name of the register into which the
1 variable will be placed.
1
1 'PARM_DECL'
1 Used to represent a parameter to a function. Treat these nodes
1 similarly to 'VAR_DECL' nodes. These nodes only appear in the
1 'DECL_ARGUMENTS' for a 'FUNCTION_DECL'.
1
1 The 'DECL_ARG_TYPE' for a 'PARM_DECL' is the type that will
1 actually be used when a value is passed to this function. It may
1 be a wider type than the 'TREE_TYPE' of the parameter; for example,
1 the ordinary type might be 'short' while the 'DECL_ARG_TYPE' is
1 'int'.
1
1 'DEBUG_EXPR_DECL'
1 Used to represent an anonymous debug-information temporary created
1 to hold an expression as it is optimized away, so that its value
1 can be referenced in debug bind statements.
1
1 'FIELD_DECL'
1 These nodes represent non-static data members. The 'DECL_SIZE' and
1 'DECL_ALIGN' behave as for 'VAR_DECL' nodes. The position of the
1 field within the parent record is specified by a combination of
1 three attributes. 'DECL_FIELD_OFFSET' is the position, counting in
1 bytes, of the 'DECL_OFFSET_ALIGN'-bit sized word containing the bit
1 of the field closest to the beginning of the structure.
1 'DECL_FIELD_BIT_OFFSET' is the bit offset of the first bit of the
1 field within this word; this may be nonzero even for fields that
1 are not bit-fields, since 'DECL_OFFSET_ALIGN' may be greater than
1 the natural alignment of the field's type.
1
1 If 'DECL_C_BIT_FIELD' holds, this field is a bit-field. In a
1 bit-field, 'DECL_BIT_FIELD_TYPE' also contains the type that was
1 originally specified for it, while DECL_TYPE may be a modified type
1 with lesser precision, according to the size of the bit field.
1
1 'NAMESPACE_DECL'
1 Namespaces provide a name hierarchy for other declarations. They
1 appear in the 'DECL_CONTEXT' of other '_DECL' nodes.
1