Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

150 lines
5.8KB

  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-2020 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 6.5, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>Plugins attr (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Plugins attr (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Plugins attr (GNU Compiler Collection (GCC) Internals)">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  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="Plugins.html#Plugins" rel="up" title="Plugins">
  30. <link href="Plugins-recording.html#Plugins-recording" rel="next" title="Plugins recording">
  31. <link href="Plugins-description.html#Plugins-description" rel="prev" title="Plugins description">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  37. blockquote.smallquotation {font-size: smaller}
  38. div.display {margin-left: 3.2em}
  39. div.example {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  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.nolinebreak {white-space: nowrap}
  54. span.roman {font-family: initial; font-weight: normal}
  55. span.sansserif {font-family: sans-serif; font-weight: normal}
  56. ul.no-bullet {list-style: none}
  57. -->
  58. </style>
  59. </head>
  60. <body lang="en">
  61. <a name="Plugins-attr"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Plugins-recording.html#Plugins-recording" accesskey="n" rel="next">Plugins recording</a>, Previous: <a href="Plugins-description.html#Plugins-description" accesskey="p" rel="prev">Plugins description</a>, Up: <a href="Plugins.html#Plugins" accesskey="u" rel="up">Plugins</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>
  65. </div>
  66. <hr>
  67. <a name="Registering-custom-attributes-or-pragmas"></a>
  68. <h3 class="section">24.6 Registering custom attributes or pragmas</h3>
  69. <p>For analysis (or other) purposes it is useful to be able to add custom
  70. attributes or pragmas.
  71. </p>
  72. <p>The <code>PLUGIN_ATTRIBUTES</code> callback is called during attribute
  73. registration. Use the <code>register_attribute</code> function to register
  74. custom attributes.
  75. </p>
  76. <div class="smallexample">
  77. <pre class="smallexample">/* Attribute handler callback */
  78. static tree
  79. handle_user_attribute (tree *node, tree name, tree args,
  80. int flags, bool *no_add_attrs)
  81. {
  82. return NULL_TREE;
  83. }
  84. /* Attribute definition */
  85. static struct attribute_spec user_attr =
  86. { &quot;user&quot;, 1, 1, false, false, false, false, handle_user_attribute, NULL };
  87. /* Plugin callback called during attribute registration.
  88. Registered with register_callback (plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL)
  89. */
  90. static void
  91. register_attributes (void *event_data, void *data)
  92. {
  93. warning (0, G_(&quot;Callback to register attributes&quot;));
  94. register_attribute (&amp;user_attr);
  95. }
  96. </pre></div>
  97. <p>The <i>PLUGIN_PRAGMAS</i> callback is called once during pragmas
  98. registration. Use the <code>c_register_pragma</code>,
  99. <code>c_register_pragma_with_data</code>,
  100. <code>c_register_pragma_with_expansion</code>,
  101. <code>c_register_pragma_with_expansion_and_data</code> functions to register
  102. custom pragmas and their handlers (which often want to call
  103. <code>pragma_lex</code>) from <samp>c-family/c-pragma.h</samp>.
  104. </p>
  105. <div class="smallexample">
  106. <pre class="smallexample">/* Plugin callback called during pragmas registration. Registered with
  107. register_callback (plugin_name, PLUGIN_PRAGMAS,
  108. register_my_pragma, NULL);
  109. */
  110. static void
  111. register_my_pragma (void *event_data, void *data)
  112. {
  113. warning (0, G_(&quot;Callback to register pragmas&quot;));
  114. c_register_pragma (&quot;GCCPLUGIN&quot;, &quot;sayhello&quot;, handle_pragma_sayhello);
  115. }
  116. </pre></div>
  117. <p>It is suggested to pass <code>&quot;GCCPLUGIN&quot;</code> (or a short name identifying
  118. your plugin) as the &ldquo;space&rdquo; argument of your pragma.
  119. </p>
  120. <p>Pragmas registered with <code>c_register_pragma_with_expansion</code> or
  121. <code>c_register_pragma_with_expansion_and_data</code> support
  122. preprocessor expansions. For example:
  123. </p>
  124. <div class="smallexample">
  125. <pre class="smallexample">#define NUMBER 10
  126. #pragma GCCPLUGIN foothreshold (NUMBER)
  127. </pre></div>
  128. </body>
  129. </html>