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