<html lang="en"> <head> <title>Function Properties - GNU Compiler Collection (GCC) Internals</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="GNU Compiler Collection (GCC) Internals"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Functions.html#Functions" title="Functions"> <link rel="prev" href="Function-Basics.html#Function-Basics" title="Function Basics"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <!-- Copyright (C) 1988-2015 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with the Invariant Sections being ``Funding Free Software'', the Front-Cover Texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the section entitled ``GNU Free Documentation License''. (a) The FSF's Front-Cover Text is: A GNU Manual (b) The FSF's Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development.--> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="Function-Properties"></a> <p> Previous: <a rel="previous" accesskey="p" href="Function-Basics.html#Function-Basics">Function Basics</a>, Up: <a rel="up" accesskey="u" href="Functions.html#Functions">Functions</a> <hr> </div> <h4 class="subsection">10.8.2 Function Properties</h4> <p><a name="index-function-properties-1980"></a><a name="index-statements-1981"></a> To determine the scope of a function, you can use the <code>DECL_CONTEXT</code> macro. This macro will return the class (either a <code>RECORD_TYPE</code> or a <code>UNION_TYPE</code>) or namespace (a <code>NAMESPACE_DECL</code>) 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. <p>In C, the <code>DECL_CONTEXT</code> 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 <code>DECL_CONTEXT</code> for the referenced <code>VAR_DECL</code>. If the <code>DECL_CONTEXT</code> for the referenced <code>VAR_DECL</code> is not the same as the function currently being processed, and neither <code>DECL_EXTERNAL</code> nor <code>TREE_STATIC</code> hold, then the reference is to a local variable in a containing function, and the back end must take appropriate action. <dl> <dt><code>DECL_EXTERNAL</code><a name="index-DECL_005fEXTERNAL-1982"></a><dd>This predicate holds if the function is undefined. <br><dt><code>TREE_PUBLIC</code><a name="index-TREE_005fPUBLIC-1983"></a><dd>This predicate holds if the function has external linkage. <br><dt><code>TREE_STATIC</code><a name="index-TREE_005fSTATIC-1984"></a><dd>This predicate holds if the function has been defined. <br><dt><code>TREE_THIS_VOLATILE</code><a name="index-TREE_005fTHIS_005fVOLATILE-1985"></a><dd>This predicate holds if the function does not return normally. <br><dt><code>TREE_READONLY</code><a name="index-TREE_005fREADONLY-1986"></a><dd>This predicate holds if the function can only read its arguments. <br><dt><code>DECL_PURE_P</code><a name="index-DECL_005fPURE_005fP-1987"></a><dd>This predicate holds if the function can only read its arguments, but may also read global memory. <br><dt><code>DECL_VIRTUAL_P</code><a name="index-DECL_005fVIRTUAL_005fP-1988"></a><dd>This predicate holds if the function is virtual. <br><dt><code>DECL_ARTIFICIAL</code><a name="index-DECL_005fARTIFICIAL-1989"></a><dd>This macro holds if the function was implicitly generated by the compiler, rather than explicitly declared. In addition to implicitly generated class member functions, this macro holds for the special functions created to implement static initialization and destruction, to compute run-time type information, and so forth. <br><dt><code>DECL_FUNCTION_SPECIFIC_TARGET</code><a name="index-DECL_005fFUNCTION_005fSPECIFIC_005fTARGET-1990"></a><dd>This macro returns a tree node that holds the target options that are to be used to compile this particular function or <code>NULL_TREE</code> if the function is to be compiled with the target options specified on the command line. <br><dt><code>DECL_FUNCTION_SPECIFIC_OPTIMIZATION</code><a name="index-DECL_005fFUNCTION_005fSPECIFIC_005fOPTIMIZATION-1991"></a><dd>This macro returns a tree node that holds the optimization options that are to be used to compile this particular function or <code>NULL_TREE</code> if the function is to be compiled with the optimization options specified on the command line. </dl> <!-- --> <!-- Language-dependent trees --> <!-- --> </body></html>