Next:Internal structure, Up:Declarations [Contents][Index]
Some macros can be used with any kind of declaration. These include:
DECL_NAME ¶This macro returns anIDENTIFIER_NODE giving the name of theentity.
TREE_TYPE ¶This macro returns the type of the entity declared.
EXPR_FILENAME ¶This macro returns the name of the file in which the entity wasdeclared, as achar*. For an entity declared implicitly by thecompiler (like__builtin_memcpy), this will be the string"<internal>".
EXPR_LINENO ¶This macro returns the line number at which the entity was declared, asanint.
DECL_ARTIFICIAL ¶This predicate holds if the declaration was implicitly generated by thecompiler. For example, this predicate will hold of an implicitlydeclared member function, or of theTYPE_DECL implicitlygenerated 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 generatedtypedef declaration is represented by aTYPE_DECL for whichDECL_ARTIFICIAL holds.
The various kinds of declarations include:
LABEL_DECLThese nodes are used to represent labels in function bodies. For moreinformation, seeFunctions. These nodes only appear in blockscopes.
CONST_DECLThese nodes are used to represent enumeration constants. The value ofthe constant is given byDECL_INITIAL which will be anINTEGER_CST with the same type as theTREE_TYPE of theCONST_DECL, i.e., anENUMERAL_TYPE.
RESULT_DECLThese nodes represent the value returned by a function. When a value isassigned to aRESULT_DECL, that indicates that the value shouldbe returned, via bitwise copy, by the function. You can useDECL_SIZE andDECL_ALIGN on aRESULT_DECL, just aswith aVAR_DECL.
TYPE_DECLThese nodes representtypedef declarations. TheTREE_TYPEis the type declared to have the name given byDECL_NAME. Insome cases, there is no associated name.
VAR_DECLThese nodes represent variables with namespace or block scope, as wellas static data members. TheDECL_SIZE andDECL_ALIGN areanalogous toTYPE_SIZE andTYPE_ALIGN. For a declaration,you should always use theDECL_SIZE andDECL_ALIGN ratherthan theTYPE_SIZE andTYPE_ALIGN given by theTREE_TYPE, since special attributes may have been applied to thevariable to give it a particular size and alignment. You may use thepredicatesDECL_THIS_STATIC orDECL_THIS_EXTERN to testwhether the storage class specifiersstatic orextern wereused to declare a variable.
If this variable is initialized (but does not require a constructor),theDECL_INITIAL will be an expression for the initializer. Theinitializer should be evaluated, and a bitwise copy into the variableperformed. If theDECL_INITIAL is theerror_mark_node,there is an initializer, but it is given by an explicit statement laterin the code; no bitwise copy is required.
GCC provides an extension that allows either automatic variables, orglobal variables, to be placed in particular registers. This extensionis being used for a particularVAR_DECL ifDECL_REGISTERholds for theVAR_DECL, and ifDECL_ASSEMBLER_NAME is notequal toDECL_NAME. In that case,DECL_ASSEMBLER_NAME isthe name of the register into which the variable will be placed.
PARM_DECLUsed to represent a parameter to a function. Treat these nodessimilarly toVAR_DECL nodes. These nodes only appear in theDECL_ARGUMENTS for aFUNCTION_DECL.
TheDECL_ARG_TYPE for aPARM_DECL is the type that willactually be used when a value is passed to this function. It may be awider type than theTREE_TYPE of the parameter; for example, theordinary type might beshort while theDECL_ARG_TYPE isint.
DEBUG_EXPR_DECLUsed to represent an anonymous debug-information temporary created tohold an expression as it is optimized away, so that its value can bereferenced in debug bind statements.
FIELD_DECLThese nodes represent non-static data members. TheDECL_SIZE andDECL_ALIGN behave as forVAR_DECL nodes.The position of the field within the parent record is specified by acombination of three attributes.DECL_FIELD_OFFSET is the position,counting in bytes, of theDECL_OFFSET_ALIGN-bit sized word containingthe bit of the field closest to the beginning of the structure.DECL_FIELD_BIT_OFFSET is the bit offset of the first bit of the fieldwithin this word; this may be nonzero even for fields that are not bit-fields,sinceDECL_OFFSET_ALIGN may be greater than the natural alignmentof the field’s type.
IfDECL_C_BIT_FIELD holds, this field is a bit-field. In a bit-field,DECL_BIT_FIELD_TYPE also contains the type that was originallyspecified for it, while DECL_TYPE may be a modified type with lesser precision,according to the size of the bit field.
NAMESPACE_DECLNamespaces provide a name hierarchy for other declarations. Theyappear in theDECL_CONTEXT of other_DECL nodes.
Next:Internal structure, Up:Declarations [Contents][Index]