builtin-attrs.def 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. /* Copyright (C) 2001-2019 Free Software Foundation, Inc.
  2. Contributed by Joseph Myers <jsm28@cam.ac.uk>.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify it under
  5. the terms of the GNU General Public License as published by the Free
  6. Software Foundation; either version 3, or (at your option) any later
  7. version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  9. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  11. for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GCC; see the file COPYING3. If not see
  14. <http://www.gnu.org/licenses/>. */
  15. /* This header provides a declarative way of describing the attributes
  16. that are applied to some built-in functions by default. Attributes
  17. that are meant to be used by user-defined functions but aren't used
  18. by any built-ins, or attributes that apply to types or variables
  19. but not to functions need not and should not be defined here.
  20. Before including this header, you must define the following macros.
  21. In each case where there is an ENUM, it is an identifier used to
  22. reference the tree in subsequent definitions.
  23. DEF_ATTR_NULL_TREE (ENUM)
  24. Constructs a NULL_TREE.
  25. DEF_ATTR_INT (ENUM, VALUE)
  26. Constructs an INTEGER_CST with value VALUE (an integer representable
  27. in HOST_WIDE_INT).
  28. DEF_ATTR_IDENT (ENUM, STRING)
  29. Constructs an IDENTIFIER_NODE for STRING.
  30. DEF_ATTR_TREE_LIST (ENUM, PURPOSE, VALUE, CHAIN)
  31. Constructs a TREE_LIST with given PURPOSE, VALUE and CHAIN (given
  32. as previous ENUM names). */
  33. DEF_ATTR_NULL_TREE (ATTR_NULL)
  34. /* Construct a tree for a given integer and a list containing it. */
  35. #define DEF_ATTR_FOR_INT(VALUE) \
  36. DEF_ATTR_INT (ATTR_##VALUE, VALUE) \
  37. DEF_ATTR_TREE_LIST (ATTR_LIST_##VALUE, ATTR_NULL, \
  38. ATTR_##VALUE, ATTR_NULL)
  39. DEF_ATTR_FOR_INT (0)
  40. DEF_ATTR_FOR_INT (1)
  41. DEF_ATTR_FOR_INT (2)
  42. DEF_ATTR_FOR_INT (3)
  43. DEF_ATTR_FOR_INT (4)
  44. DEF_ATTR_FOR_INT (5)
  45. DEF_ATTR_FOR_INT (6)
  46. #undef DEF_ATTR_FOR_INT
  47. /* Construct a tree for a given string and a list containing it. */
  48. #define DEF_ATTR_FOR_STRING(ENUM, VALUE) \
  49. DEF_ATTR_STRING (ATTR_##ENUM, VALUE) \
  50. DEF_ATTR_TREE_LIST (ATTR_LIST_##ENUM, ATTR_NULL, \
  51. ATTR_##ENUM, ATTR_NULL)
  52. DEF_ATTR_FOR_STRING (STR1, "1")
  53. #undef DEF_ATTR_FOR_STRING
  54. /* Construct a tree for a list of two integers. */
  55. #define DEF_LIST_INT_INT(VALUE1, VALUE2) \
  56. DEF_ATTR_TREE_LIST (ATTR_LIST_##VALUE1##_##VALUE2, ATTR_NULL, \
  57. ATTR_##VALUE1, ATTR_LIST_##VALUE2)
  58. DEF_LIST_INT_INT (1,0)
  59. DEF_LIST_INT_INT (1,2)
  60. DEF_LIST_INT_INT (1,3)
  61. DEF_LIST_INT_INT (1,4)
  62. DEF_LIST_INT_INT (1,5)
  63. DEF_LIST_INT_INT (2,0)
  64. DEF_LIST_INT_INT (2,3)
  65. DEF_LIST_INT_INT (3,0)
  66. DEF_LIST_INT_INT (3,4)
  67. DEF_LIST_INT_INT (4,0)
  68. DEF_LIST_INT_INT (4,5)
  69. DEF_LIST_INT_INT (5,0)
  70. DEF_LIST_INT_INT (5,6)
  71. #undef DEF_LIST_INT_INT
  72. /* Construct trees for identifiers used in built-in function attributes.
  73. The construction contributes to startup costs so only attributes that
  74. are used to define built-ins should be defined here. */
  75. DEF_ATTR_IDENT (ATTR_ALLOC_SIZE, "alloc_size")
  76. DEF_ATTR_IDENT (ATTR_COLD, "cold")
  77. DEF_ATTR_IDENT (ATTR_CONST, "const")
  78. DEF_ATTR_IDENT (ATTR_FORMAT, "format")
  79. DEF_ATTR_IDENT (ATTR_FORMAT_ARG, "format_arg")
  80. DEF_ATTR_IDENT (ATTR_MALLOC, "malloc")
  81. DEF_ATTR_IDENT (ATTR_NONNULL, "nonnull")
  82. DEF_ATTR_IDENT (ATTR_NORETURN, "noreturn")
  83. DEF_ATTR_IDENT (ATTR_NOTHROW, "nothrow")
  84. DEF_ATTR_IDENT (ATTR_LEAF, "leaf")
  85. DEF_ATTR_IDENT (ATTR_FNSPEC, "fn spec")
  86. DEF_ATTR_IDENT (ATTR_PRINTF, "printf")
  87. DEF_ATTR_IDENT (ATTR_ASM_FPRINTF, "asm_fprintf")
  88. DEF_ATTR_IDENT (ATTR_GCC_DIAG, "gcc_diag")
  89. DEF_ATTR_IDENT (ATTR_GCC_CDIAG, "gcc_cdiag")
  90. DEF_ATTR_IDENT (ATTR_GCC_CXXDIAG, "gcc_cxxdiag")
  91. DEF_ATTR_IDENT (ATTR_PURE, "pure")
  92. DEF_ATTR_IDENT (ATTR_NOVOPS, "no vops")
  93. DEF_ATTR_IDENT (ATTR_SCANF, "scanf")
  94. DEF_ATTR_IDENT (ATTR_SENTINEL, "sentinel")
  95. DEF_ATTR_IDENT (ATTR_STRFMON, "strfmon")
  96. DEF_ATTR_IDENT (ATTR_STRFTIME, "strftime")
  97. DEF_ATTR_IDENT (ATTR_TYPEGENERIC, "type generic")
  98. DEF_ATTR_IDENT (ATTR_TM_REGPARM, "*tm regparm")
  99. DEF_ATTR_IDENT (ATTR_TM_TMPURE, "transaction_pure")
  100. DEF_ATTR_IDENT (ATTR_RETURNS_TWICE, "returns_twice")
  101. DEF_ATTR_IDENT (ATTR_RETURNS_NONNULL, "returns_nonnull")
  102. DEF_ATTR_TREE_LIST (ATTR_NOVOPS_LIST, ATTR_NOVOPS, ATTR_NULL, ATTR_NULL)
  103. DEF_ATTR_TREE_LIST (ATTR_NOVOPS_LEAF_LIST, ATTR_LEAF, ATTR_NULL, ATTR_NOVOPS_LIST)
  104. DEF_ATTR_TREE_LIST (ATTR_LEAF_LIST, ATTR_LEAF, ATTR_NULL, ATTR_NULL)
  105. DEF_ATTR_TREE_LIST (ATTR_NOTHROW_LIST, ATTR_NOTHROW, ATTR_NULL, ATTR_NULL)
  106. DEF_ATTR_TREE_LIST (ATTR_NOTHROW_LEAF_LIST, ATTR_LEAF, ATTR_NULL, ATTR_NOTHROW_LIST)
  107. DEF_ATTR_TREE_LIST (ATTR_NOVOPS_NOTHROW_LEAF_LIST, ATTR_NOVOPS, \
  108. ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
  109. DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_LIST, ATTR_CONST, \
  110. ATTR_NULL, ATTR_NOTHROW_LIST)
  111. DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_LEAF_LIST, ATTR_CONST, \
  112. ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
  113. DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_LIST, ATTR_PURE, \
  114. ATTR_NULL, ATTR_NOTHROW_LIST)
  115. DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_LEAF_LIST, ATTR_PURE, \
  116. ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
  117. DEF_ATTR_TREE_LIST (ATTR_NORETURN_NOTHROW_LIST, ATTR_NORETURN, \
  118. ATTR_NULL, ATTR_NOTHROW_LIST)
  119. DEF_ATTR_TREE_LIST (ATTR_NORETURN_NOTHROW_LEAF_LIST, ATTR_NORETURN,\
  120. ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
  121. DEF_ATTR_TREE_LIST (ATTR_NORETURN_NOTHROW_LEAF_COLD_LIST, ATTR_COLD,\
  122. ATTR_NULL, ATTR_NORETURN_NOTHROW_LEAF_LIST)
  123. DEF_ATTR_TREE_LIST (ATTR_RT_NOTHROW_LEAF_LIST, ATTR_RETURNS_TWICE,\
  124. ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
  125. DEF_ATTR_TREE_LIST (ATTR_COLD_NOTHROW_LEAF_LIST, ATTR_COLD,\
  126. ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
  127. DEF_ATTR_TREE_LIST (ATTR_COLD_NORETURN_NOTHROW_LEAF_LIST, ATTR_COLD,\
  128. ATTR_NULL, ATTR_NORETURN_NOTHROW_LEAF_LIST)
  129. DEF_ATTR_TREE_LIST (ATTR_CONST_NORETURN_NOTHROW_LEAF_LIST, ATTR_CONST,\
  130. ATTR_NULL, ATTR_NORETURN_NOTHROW_LEAF_LIST)
  131. DEF_ATTR_TREE_LIST (ATTR_CONST_NORETURN_NOTHROW_LEAF_COLD_LIST, ATTR_COLD,\
  132. ATTR_NULL, ATTR_CONST_NORETURN_NOTHROW_LEAF_LIST)
  133. DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_LIST, ATTR_MALLOC, \
  134. ATTR_NULL, ATTR_NOTHROW_LIST)
  135. DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_LEAF_LIST, ATTR_MALLOC, \
  136. ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
  137. DEF_ATTR_TREE_LIST (ATTR_SENTINEL_NOTHROW_LIST, ATTR_SENTINEL, \
  138. ATTR_NULL, ATTR_NOTHROW_LIST)
  139. DEF_ATTR_TREE_LIST (ATTR_SENTINEL_NOTHROW_LEAF_LIST, ATTR_SENTINEL, \
  140. ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
  141. DEF_ATTR_TREE_LIST (ATTR_COLD_CONST_NORETURN_NOTHROW_LEAF_LIST, ATTR_CONST,\
  142. ATTR_NULL, ATTR_COLD_NORETURN_NOTHROW_LEAF_LIST)
  143. /* Allocation functions like malloc and realloc whose first argument
  144. with _SIZE_1, or second argument with _SIZE_2, specifies the size
  145. of the allocated object. */
  146. DEF_ATTR_TREE_LIST (ATTR_MALLOC_SIZE_1_NOTHROW_LIST, ATTR_ALLOC_SIZE, \
  147. ATTR_LIST_1, ATTR_MALLOC_NOTHROW_LIST)
  148. DEF_ATTR_TREE_LIST (ATTR_ALLOC_SIZE_2_NOTHROW_LIST, ATTR_ALLOC_SIZE, \
  149. ATTR_LIST_2, ATTR_MALLOC_NOTHROW_LIST)
  150. DEF_ATTR_TREE_LIST (ATTR_MALLOC_SIZE_1_NOTHROW_LEAF_LIST, ATTR_ALLOC_SIZE, \
  151. ATTR_LIST_1, ATTR_MALLOC_NOTHROW_LEAF_LIST)
  152. /* Alloca is just like malloc except that it never returns null. */
  153. DEF_ATTR_TREE_LIST (ATTR_ALLOCA_SIZE_1_NOTHROW_LEAF_LIST, ATTR_RETURNS_NONNULL,
  154. ATTR_NULL, ATTR_MALLOC_SIZE_1_NOTHROW_LEAF_LIST)
  155. /* Allocation functions like calloc the product of whose first two arguments
  156. specifies the size of the allocated object. */
  157. DEF_ATTR_TREE_LIST (ATTR_MALLOC_SIZE_1_2_NOTHROW_LEAF_LIST, ATTR_ALLOC_SIZE, \
  158. ATTR_LIST_1_2, ATTR_MALLOC_NOTHROW_LEAF_LIST)
  159. /* Allocation functions like realloc whose second argument specifies
  160. the size of the allocated object. */
  161. DEF_ATTR_TREE_LIST (ATTR_ALLOC_SIZE_2_NOTHROW_LEAF_LIST, ATTR_ALLOC_SIZE, \
  162. ATTR_LIST_2, ATTR_NOTHROW_LEAF_LIST)
  163. /* Functions whose pointer parameter(s) are all nonnull. */
  164. DEF_ATTR_TREE_LIST (ATTR_NONNULL_LIST, ATTR_NONNULL, ATTR_NULL, ATTR_NULL)
  165. /* Functions whose first parameter is a nonnull pointer. */
  166. DEF_ATTR_TREE_LIST (ATTR_NONNULL_1, ATTR_NONNULL, ATTR_LIST_1, ATTR_NULL)
  167. /* Functions whose second parameter is a nonnull pointer. */
  168. DEF_ATTR_TREE_LIST (ATTR_NONNULL_2, ATTR_NONNULL, ATTR_LIST_2, ATTR_NULL)
  169. /* Functions whose third parameter is a nonnull pointer. */
  170. DEF_ATTR_TREE_LIST (ATTR_NONNULL_3, ATTR_NONNULL, ATTR_LIST_3, ATTR_NULL)
  171. /* Nothrow functions with the sentinel(1) attribute. */
  172. DEF_ATTR_TREE_LIST (ATTR_NOTHROW_SENTINEL_1, ATTR_SENTINEL, ATTR_LIST_1, \
  173. ATTR_NOTHROW_LIST)
  174. /* Nothrow functions whose pointer parameter(s) are all nonnull. */
  175. DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL, ATTR_NONNULL, ATTR_NULL, \
  176. ATTR_NOTHROW_LIST)
  177. /* Nothrow leaf functions whose pointer parameter(s) are all nonnull. */
  178. DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_LEAF, ATTR_NONNULL, ATTR_NULL, \
  179. ATTR_NOTHROW_LEAF_LIST)
  180. DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_LEAF_LIST, ATTR_LEAF, ATTR_NULL, ATTR_NOTHROW_NONNULL_LEAF)
  181. /* Nothrow functions whose first parameter is a nonnull pointer. */
  182. DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_1, ATTR_NONNULL, ATTR_LIST_1, \
  183. ATTR_NOTHROW_LIST)
  184. /* Nothrow functions whose second parameter is a nonnull pointer. */
  185. DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_2, ATTR_NONNULL, ATTR_LIST_2, \
  186. ATTR_NOTHROW_LIST)
  187. /* Nothrow functions whose third parameter is a nonnull pointer. */
  188. DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_3, ATTR_NONNULL, ATTR_LIST_3, \
  189. ATTR_NOTHROW_LIST)
  190. /* Nothrow functions whose fourth parameter is a nonnull pointer. */
  191. DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_4, ATTR_NONNULL, ATTR_LIST_4, \
  192. ATTR_NOTHROW_LIST)
  193. /* Nothrow functions whose fifth parameter is a nonnull pointer. */
  194. DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_5, ATTR_NONNULL, ATTR_LIST_5, \
  195. ATTR_NOTHROW_LIST)
  196. /* Same as ATTR_NONNULL_1. */
  197. DEF_ATTR_TREE_LIST (ATTR_NONNULL_1_1, ATTR_NONNULL, ATTR_LIST_1, ATTR_NULL)
  198. /* Functions like {v,}fprintf whose first and second parameters are
  199. nonnull pointers. As cancellation points the functions are not
  200. nothrow. */
  201. DEF_ATTR_TREE_LIST (ATTR_NONNULL_1_2, ATTR_NONNULL, ATTR_LIST_1_2, ATTR_NULL)
  202. /* The following don't have {v,}fprintf forms. They exist only to
  203. make it possible to declare {v,}{f,s}printf attributes using
  204. the same macro. */
  205. DEF_ATTR_TREE_LIST (ATTR_NONNULL_1_3, ATTR_NONNULL, ATTR_LIST_1_3, ATTR_NULL)
  206. DEF_ATTR_TREE_LIST (ATTR_NONNULL_1_4, ATTR_NONNULL, ATTR_LIST_1_4, ATTR_NULL)
  207. DEF_ATTR_TREE_LIST (ATTR_NONNULL_1_5, ATTR_NONNULL, ATTR_LIST_1_5, ATTR_NULL)
  208. /* Same as ATTR_NOTHROW_NONNULL_1. */
  209. DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_1_1, ATTR_NONNULL, ATTR_LIST_1,
  210. ATTR_NOTHROW_LIST)
  211. /* Nothrow functions like {v,}sprintf whose first and second parameters
  212. are nonnull pointers. */
  213. DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_1_2, ATTR_NONNULL, ATTR_LIST_1_2, \
  214. ATTR_NOTHROW_LIST)
  215. /* Nothrow functions like {v,}snprintf whose first and third parameters
  216. are nonnull pointers. */
  217. DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_1_3, ATTR_NONNULL, ATTR_LIST_1_3, \
  218. ATTR_NOTHROW_LIST)
  219. /* Nothrow functions like {v,}sprintf_chk whose first and fourth parameters
  220. are nonnull pointers. */
  221. DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_1_4, ATTR_NONNULL, ATTR_LIST_1_4, \
  222. ATTR_NOTHROW_LIST)
  223. /* Nothrow functions like {v,}snprintf_chk whose first and fifth parameters
  224. are nonnull pointers. */
  225. DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_1_5, ATTR_NONNULL, ATTR_LIST_1_5, \
  226. ATTR_NOTHROW_LIST)
  227. /* Nothrow leaf functions which are type-generic. */
  228. DEF_ATTR_TREE_LIST (ATTR_NOTHROW_TYPEGENERIC_LEAF, ATTR_TYPEGENERIC, ATTR_NULL, \
  229. ATTR_NOTHROW_LEAF_LIST)
  230. /* Nothrow nonnull leaf functions that are type-generic. */
  231. DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_TYPEGENERIC_LEAF,
  232. ATTR_TYPEGENERIC, ATTR_NULL,
  233. ATTR_NOTHROW_NONNULL_LEAF)
  234. /* Nothrow const functions whose pointer parameter(s) are all nonnull. */
  235. DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_NONNULL, ATTR_CONST, ATTR_NULL, \
  236. ATTR_NOTHROW_NONNULL)
  237. /* Nothrow leaf functions whose pointer parameter(s) are all nonnull,
  238. and which return their first argument. */
  239. DEF_ATTR_TREE_LIST (ATTR_RET1_NOTHROW_NONNULL_LEAF, ATTR_FNSPEC, ATTR_LIST_STR1, \
  240. ATTR_NOTHROW_NONNULL_LEAF)
  241. /* Nothrow leaf functions whose pointer parameter(s) are all nonnull,
  242. and return value is also nonnull. */
  243. DEF_ATTR_TREE_LIST (ATTR_RETNONNULL_NOTHROW_LEAF, ATTR_RETURNS_NONNULL, ATTR_NULL, \
  244. ATTR_NOTHROW_NONNULL_LEAF)
  245. /* Nothrow const leaf functions whose pointer parameter(s) are all nonnull. */
  246. DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_NONNULL_LEAF, ATTR_CONST, ATTR_NULL, \
  247. ATTR_NOTHROW_NONNULL_LEAF)
  248. /* Nothrow const functions which are type-generic. */
  249. DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_TYPEGENERIC, ATTR_TYPEGENERIC, ATTR_NULL, \
  250. ATTR_CONST_NOTHROW_LIST)
  251. /* Nothrow const leaf functions which are type-generic. */
  252. DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF, ATTR_TYPEGENERIC, ATTR_NULL, \
  253. ATTR_CONST_NOTHROW_LEAF_LIST)
  254. /* Nothrow pure functions whose pointer parameter(s) are all nonnull. */
  255. DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_NONNULL, ATTR_PURE, ATTR_NULL, \
  256. ATTR_NOTHROW_NONNULL)
  257. /* Nothrow pure leaf functions whose pointer parameter(s) are all nonnull. */
  258. DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_NONNULL_LEAF, ATTR_PURE, ATTR_NULL, \
  259. ATTR_NOTHROW_NONNULL_LEAF)
  260. /* Nothrow malloc functions whose pointer parameter(s) are all nonnull. */
  261. DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_NONNULL, ATTR_MALLOC, ATTR_NULL, \
  262. ATTR_NOTHROW_NONNULL)
  263. /* Nothrow malloc leaf functions whose pointer parameter(s) are all nonnull. */
  264. DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_NONNULL_LEAF, ATTR_MALLOC, ATTR_NULL, \
  265. ATTR_NOTHROW_NONNULL_LEAF)
  266. /* Construct a tree for the format attribute (and implicitly nonnull). */
  267. #define DEF_FORMAT_ATTRIBUTE(TYPE, FA, VALUES) \
  268. DEF_ATTR_TREE_LIST (ATTR_##TYPE##_##VALUES, ATTR_NULL, \
  269. ATTR_##TYPE, ATTR_LIST_##VALUES) \
  270. DEF_ATTR_TREE_LIST (ATTR_FORMAT_##TYPE##_##VALUES, ATTR_FORMAT, \
  271. ATTR_##TYPE##_##VALUES, ATTR_NONNULL_##FA)
  272. /* Construct a tree for the format and nothrow attributes (format
  273. implies nonnull). */
  274. #define DEF_FORMAT_ATTRIBUTE_NOTHROW(TYPE, FA, VALUES) \
  275. DEF_ATTR_TREE_LIST (ATTR_##TYPE##_##VALUES, ATTR_NULL, \
  276. ATTR_##TYPE, ATTR_LIST_##VALUES) \
  277. DEF_ATTR_TREE_LIST (ATTR_FORMAT_##TYPE##_NOTHROW_##VALUES, ATTR_FORMAT,\
  278. ATTR_##TYPE##_##VALUES, ATTR_NOTHROW_NONNULL_##FA)
  279. /* Construct one tree for the format attribute and another for the format
  280. and nothrow attributes (in both cases format implies nonnull). */
  281. #define DEF_FORMAT_ATTRIBUTE_BOTH(TYPE, FA, VALUES) \
  282. DEF_ATTR_TREE_LIST (ATTR_##TYPE##_##VALUES, ATTR_NULL, \
  283. ATTR_##TYPE, ATTR_LIST_##VALUES) \
  284. DEF_ATTR_TREE_LIST (ATTR_FORMAT_##TYPE##_##VALUES, ATTR_FORMAT, \
  285. ATTR_##TYPE##_##VALUES, ATTR_NONNULL_##FA) \
  286. DEF_ATTR_TREE_LIST (ATTR_FORMAT_##TYPE##_NOTHROW_##VALUES, ATTR_FORMAT,\
  287. ATTR_##TYPE##_##VALUES, ATTR_NOTHROW_NONNULL_##FA)
  288. /* Construct a pair of trees for the nonnull attribute for the first
  289. argument, plus format printf attribute (format implies nonnull):
  290. the first ordinary and the second nothrow. */
  291. #define DEF_FORMAT_ATTRIBUTE_NONNULL(TYPE, FA, VALUES) \
  292. DEF_ATTR_TREE_LIST (ATTR_NONNULL_1_FORMAT_##TYPE##_##VALUES, \
  293. ATTR_FORMAT, ATTR_##TYPE##_##VALUES, \
  294. ATTR_NONNULL_1_##FA) \
  295. DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_1_FORMAT_##TYPE##_##VALUES, \
  296. ATTR_FORMAT, ATTR_##TYPE##_##VALUES, \
  297. ATTR_NOTHROW_NONNULL_1_##FA)
  298. DEF_FORMAT_ATTRIBUTE(PRINTF,1,1_0)
  299. DEF_FORMAT_ATTRIBUTE(PRINTF,1,1_2)
  300. DEF_FORMAT_ATTRIBUTE_BOTH(PRINTF,2,2_0)
  301. DEF_FORMAT_ATTRIBUTE_BOTH(PRINTF,2,2_3)
  302. DEF_FORMAT_ATTRIBUTE_BOTH(PRINTF,3,3_0)
  303. DEF_FORMAT_ATTRIBUTE_BOTH(PRINTF,3,3_4)
  304. DEF_FORMAT_ATTRIBUTE_NOTHROW(PRINTF,4,4_0)
  305. DEF_FORMAT_ATTRIBUTE_NOTHROW(PRINTF,4,4_5)
  306. DEF_FORMAT_ATTRIBUTE_NOTHROW(PRINTF,5,5_0)
  307. DEF_FORMAT_ATTRIBUTE_NOTHROW(PRINTF,5,5_6)
  308. /* Attributes for fprintf(f, f, va). */
  309. DEF_FORMAT_ATTRIBUTE_NONNULL(PRINTF,1,1_2)
  310. /* Attributes for v{f,s}printf(d, f, va). vsprintf is nothrow, vfprintf
  311. is not. */
  312. DEF_FORMAT_ATTRIBUTE_NONNULL(PRINTF,2,2_0)
  313. /* Attributes for {f,s}printf(d, f, ...). sprintf is nothrow, fprintf
  314. is not. */
  315. DEF_FORMAT_ATTRIBUTE_NONNULL(PRINTF,2,2_3)
  316. /* Attributes for vprintf_chk. */
  317. DEF_FORMAT_ATTRIBUTE_NONNULL(PRINTF,3,3_0)
  318. /* Attributes for printf_chk. */
  319. DEF_FORMAT_ATTRIBUTE_NONNULL(PRINTF,3,3_4)
  320. /* Attributes for v{f,s}printf_chk(d, t, bos, f, va). vsprintf_chk is
  321. nothrow, vfprintf_chk is not. */
  322. DEF_FORMAT_ATTRIBUTE_NONNULL(PRINTF,4,4_0)
  323. /* Attributes for {f,s}printf_chk(d, t, bos, f, ...). sprintf_chk is
  324. nothrow, fprintf_chk is not. */
  325. DEF_FORMAT_ATTRIBUTE_NONNULL(PRINTF,4,4_5)
  326. DEF_FORMAT_ATTRIBUTE(SCANF,1,1_0)
  327. DEF_FORMAT_ATTRIBUTE(SCANF,1,1_2)
  328. DEF_FORMAT_ATTRIBUTE_BOTH(SCANF,2,2_0)
  329. DEF_FORMAT_ATTRIBUTE_BOTH(SCANF,2,2_3)
  330. DEF_FORMAT_ATTRIBUTE_NOTHROW(STRFTIME,3,3_0)
  331. DEF_FORMAT_ATTRIBUTE_NOTHROW(STRFMON,3,3_4)
  332. #undef DEF_FORMAT_ATTRIBUTE
  333. #undef DEF_FORMAT_ATTRIBUTE_NOTHROW
  334. #undef DEF_FORMAT_ATTRIBUTE_BOTH
  335. /* Transactional memory variants of the above. */
  336. DEF_ATTR_TREE_LIST (ATTR_TM_NOTHROW_LIST,
  337. ATTR_TM_REGPARM, ATTR_NULL, ATTR_NOTHROW_LIST)
  338. DEF_ATTR_TREE_LIST (ATTR_TM_TMPURE_NOTHROW_LIST,
  339. ATTR_TM_TMPURE, ATTR_NULL, ATTR_TM_NOTHROW_LIST)
  340. DEF_ATTR_TREE_LIST (ATTR_TM_PURE_TMPURE_NOTHROW_LIST,
  341. ATTR_PURE, ATTR_NULL, ATTR_TM_TMPURE_NOTHROW_LIST)
  342. DEF_ATTR_TREE_LIST (ATTR_TM_NORETURN_NOTHROW_LIST,
  343. ATTR_TM_REGPARM, ATTR_NULL, ATTR_NORETURN_NOTHROW_LIST)
  344. DEF_ATTR_TREE_LIST (ATTR_TM_CONST_NOTHROW_LIST,
  345. ATTR_TM_REGPARM, ATTR_NULL, ATTR_CONST_NOTHROW_LIST)
  346. DEF_ATTR_TREE_LIST (ATTR_TM_NOTHROW_RT_LIST,
  347. ATTR_RETURNS_TWICE, ATTR_NULL, ATTR_TM_NOTHROW_LIST)
  348. /* Same attributes used for BUILT_IN_MALLOC except with TM_PURE thrown in. */
  349. DEF_ATTR_TREE_LIST (ATTR_TMPURE_MALLOC_NOTHROW_LIST,
  350. ATTR_TM_TMPURE, ATTR_NULL, ATTR_MALLOC_NOTHROW_LIST)
  351. /* Same attributes used for BUILT_IN_FREE except with TM_PURE thrown in. */
  352. DEF_ATTR_TREE_LIST (ATTR_TMPURE_NOTHROW_LIST,
  353. ATTR_TM_TMPURE, ATTR_NULL, ATTR_NOTHROW_LIST)
  354. DEF_ATTR_TREE_LIST (ATTR_TMPURE_NOTHROW_LEAF_LIST,
  355. ATTR_TM_TMPURE, ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
  356. DEF_ATTR_TREE_LIST (ATTR_TMPURE_NORETURN_NOTHROW_LEAF_LIST,
  357. ATTR_TM_TMPURE, ATTR_NULL, ATTR_NORETURN_NOTHROW_LEAF_LIST)
  358. DEF_ATTR_TREE_LIST (ATTR_TMPURE_NORETURN_NOTHROW_LEAF_COLD_LIST,
  359. ATTR_COLD, ATTR_NULL,
  360. ATTR_TMPURE_NORETURN_NOTHROW_LEAF_LIST)
  361. /* Construct a tree for a format_arg attribute. */
  362. #define DEF_FORMAT_ARG_ATTRIBUTE(FA) \
  363. DEF_ATTR_TREE_LIST (ATTR_FORMAT_ARG_##FA, ATTR_FORMAT_ARG, \
  364. ATTR_LIST_##FA, ATTR_NOTHROW_NONNULL_##FA)
  365. DEF_FORMAT_ARG_ATTRIBUTE(1)
  366. DEF_FORMAT_ARG_ATTRIBUTE(2)
  367. #undef DEF_FORMAT_ARG_ATTRIBUTE