comparison gcc/builtin-attrs.def @ 16:04ced10e8804

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