Function-Properties.html 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2017 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <title>GNU Compiler Collection (GCC) Internals: Function Properties</title>
  20. <meta name="description" content="GNU Compiler Collection (GCC) Internals: Function Properties">
  21. <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Function Properties">
  22. <meta name="resource-type" content="document">
  23. <meta name="distribution" content="global">
  24. <meta name="Generator" content="makeinfo">
  25. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="Functions.html#Functions" rel="up" title="Functions">
  30. <link href="Language_002ddependent-trees.html#Language_002ddependent-trees" rel="next" title="Language-dependent trees">
  31. <link href="Function-Basics.html#Function-Basics" rel="prev" title="Function Basics">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.smallquotation {font-size: smaller}
  36. div.display {margin-left: 3.2em}
  37. div.example {margin-left: 3.2em}
  38. div.indentedblock {margin-left: 3.2em}
  39. div.lisp {margin-left: 3.2em}
  40. div.smalldisplay {margin-left: 3.2em}
  41. div.smallexample {margin-left: 3.2em}
  42. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style:oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nocodebreak {white-space:nowrap}
  54. span.nolinebreak {white-space:nowrap}
  55. span.roman {font-family:serif; font-weight:normal}
  56. span.sansserif {font-family:sans-serif; font-weight:normal}
  57. ul.no-bullet {list-style: none}
  58. -->
  59. </style>
  60. </head>
  61. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  62. <a name="Function-Properties"></a>
  63. <div class="header">
  64. <p>
  65. Previous: <a href="Function-Basics.html#Function-Basics" accesskey="p" rel="prev">Function Basics</a>, Up: <a href="Functions.html#Functions" accesskey="u" rel="up">Functions</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  66. </div>
  67. <hr>
  68. <a name="Function-Properties-1"></a>
  69. <h4 class="subsection">10.8.2 Function Properties</h4>
  70. <a name="index-function-properties"></a>
  71. <a name="index-statements"></a>
  72. <p>To determine the scope of a function, you can use the
  73. <code>DECL_CONTEXT</code> macro. This macro will return the class
  74. (either a <code>RECORD_TYPE</code> or a <code>UNION_TYPE</code>) or namespace (a
  75. <code>NAMESPACE_DECL</code>) of which the function is a member. For a virtual
  76. function, this macro returns the class in which the function was
  77. actually defined, not the base class in which the virtual declaration
  78. occurred.
  79. </p>
  80. <p>In C, the <code>DECL_CONTEXT</code> for a function maybe another function.
  81. This representation indicates that the GNU nested function extension
  82. is in use. For details on the semantics of nested functions, see the
  83. GCC Manual. The nested function can refer to local variables in its
  84. containing function. Such references are not explicitly marked in the
  85. tree structure; back ends must look at the <code>DECL_CONTEXT</code> for the
  86. referenced <code>VAR_DECL</code>. If the <code>DECL_CONTEXT</code> for the
  87. referenced <code>VAR_DECL</code> is not the same as the function currently
  88. being processed, and neither <code>DECL_EXTERNAL</code> nor
  89. <code>TREE_STATIC</code> hold, then the reference is to a local variable in
  90. a containing function, and the back end must take appropriate action.
  91. </p>
  92. <dl compact="compact">
  93. <dt><code>DECL_EXTERNAL</code>
  94. <a name="index-DECL_005fEXTERNAL-1"></a>
  95. </dt>
  96. <dd><p>This predicate holds if the function is undefined.
  97. </p>
  98. </dd>
  99. <dt><code>TREE_PUBLIC</code>
  100. <a name="index-TREE_005fPUBLIC-1"></a>
  101. </dt>
  102. <dd><p>This predicate holds if the function has external linkage.
  103. </p>
  104. </dd>
  105. <dt><code>TREE_STATIC</code>
  106. <a name="index-TREE_005fSTATIC"></a>
  107. </dt>
  108. <dd><p>This predicate holds if the function has been defined.
  109. </p>
  110. </dd>
  111. <dt><code>TREE_THIS_VOLATILE</code>
  112. <a name="index-TREE_005fTHIS_005fVOLATILE"></a>
  113. </dt>
  114. <dd><p>This predicate holds if the function does not return normally.
  115. </p>
  116. </dd>
  117. <dt><code>TREE_READONLY</code>
  118. <a name="index-TREE_005fREADONLY"></a>
  119. </dt>
  120. <dd><p>This predicate holds if the function can only read its arguments.
  121. </p>
  122. </dd>
  123. <dt><code>DECL_PURE_P</code>
  124. <a name="index-DECL_005fPURE_005fP"></a>
  125. </dt>
  126. <dd><p>This predicate holds if the function can only read its arguments, but
  127. may also read global memory.
  128. </p>
  129. </dd>
  130. <dt><code>DECL_VIRTUAL_P</code>
  131. <a name="index-DECL_005fVIRTUAL_005fP"></a>
  132. </dt>
  133. <dd><p>This predicate holds if the function is virtual.
  134. </p>
  135. </dd>
  136. <dt><code>DECL_ARTIFICIAL</code>
  137. <a name="index-DECL_005fARTIFICIAL-2"></a>
  138. </dt>
  139. <dd><p>This macro holds if the function was implicitly generated by the
  140. compiler, rather than explicitly declared. In addition to implicitly
  141. generated class member functions, this macro holds for the special
  142. functions created to implement static initialization and destruction, to
  143. compute run-time type information, and so forth.
  144. </p>
  145. </dd>
  146. <dt><code>DECL_FUNCTION_SPECIFIC_TARGET</code>
  147. <a name="index-DECL_005fFUNCTION_005fSPECIFIC_005fTARGET-1"></a>
  148. </dt>
  149. <dd><p>This macro returns a tree node that holds the target options that are
  150. to be used to compile this particular function or <code>NULL_TREE</code> if
  151. the function is to be compiled with the target options specified on
  152. the command line.
  153. </p>
  154. </dd>
  155. <dt><code>DECL_FUNCTION_SPECIFIC_OPTIMIZATION</code>
  156. <a name="index-DECL_005fFUNCTION_005fSPECIFIC_005fOPTIMIZATION-1"></a>
  157. </dt>
  158. <dd><p>This macro returns a tree node that holds the optimization options
  159. that are to be used to compile this particular function or
  160. <code>NULL_TREE</code> if the function is to be compiled with the
  161. optimization options specified on the command line.
  162. </p>
  163. </dd>
  164. </dl>
  165. <hr>
  166. <div class="header">
  167. <p>
  168. Previous: <a href="Function-Basics.html#Function-Basics" accesskey="p" rel="prev">Function Basics</a>, Up: <a href="Functions.html#Functions" accesskey="u" rel="up">Functions</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  169. </div>
  170. </body>
  171. </html>