Previous: Function Basics, Up: Functions
To determine the scope of a function, you can use the
DECL_CONTEXT
macro. This macro will return the class
(either a RECORD_TYPE
or a UNION_TYPE
) or namespace (a
NAMESPACE_DECL
) of which the function is a member. For a virtual
function, this macro returns the class in which the function was
actually defined, not the base class in which the virtual declaration
occurred.
In C, the DECL_CONTEXT
for a function maybe another function.
This representation indicates that the GNU nested function extension
is in use. For details on the semantics of nested functions, see the
GCC Manual. The nested function can refer to local variables in its
containing function. Such references are not explicitly marked in the
tree structure; back ends must look at the DECL_CONTEXT
for the
referenced VAR_DECL
. If the DECL_CONTEXT
for the
referenced VAR_DECL
is not the same as the function currently
being processed, and neither DECL_EXTERNAL
nor
TREE_STATIC
hold, then the reference is to a local variable in
a containing function, and the back end must take appropriate action.
DECL_EXTERNAL
TREE_PUBLIC
TREE_STATIC
TREE_THIS_VOLATILE
TREE_READONLY
DECL_PURE_P
DECL_VIRTUAL_P
DECL_ARTIFICIAL
DECL_FUNCTION_SPECIFIC_TARGET
NULL_TREE
if
the function is to be compiled with the target options specified on
the command line.
DECL_FUNCTION_SPECIFIC_OPTIMIZATION
NULL_TREE
if the function is to be compiled with the
optimization options specified on the command line.
There are tree nodes corresponding to all of the source-level statement constructs, used within the C and C++ frontends. These are enumerated here, together with a list of the various macros that can be used to obtain information about them. There are a few macros that can be used with all statements: