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