* prerequisites.xml: Refer to GCC (instead of gcc) and GNU/Linux.
[official-gcc.git] / gcc / builtin-attrs.def
blobd0c3d9605ea525471a11cd4e0622f83907e7a80c
1 /* Copyright (C) 2001, 2002, 2004, 2005, 2007, 2010
2 Free Software Foundation, Inc.
3 Contributed by Joseph Myers <jsm28@cam.ac.uk>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 /* This header provides a declarative way of describing the attributes
22 that are applied to some functions by default.
24 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
26 reference the tree in subsequent definitions.
28 DEF_ATTR_NULL_TREE (ENUM)
30 Constructs a NULL_TREE.
32 DEF_ATTR_INT (ENUM, VALUE)
34 Constructs an INTEGER_CST with value VALUE (an integer representable
35 in HOST_WIDE_INT).
37 DEF_ATTR_IDENT (ENUM, STRING)
39 Constructs an IDENTIFIER_NODE for STRING.
41 DEF_ATTR_TREE_LIST (ENUM, PURPOSE, VALUE, CHAIN)
43 Constructs a TREE_LIST with given PURPOSE, VALUE and CHAIN (given
44 as previous ENUM names). */
46 DEF_ATTR_NULL_TREE (ATTR_NULL)
48 /* Construct a tree for a given integer and a list containing it. */
49 #define DEF_ATTR_FOR_INT(VALUE) \
50 DEF_ATTR_INT (ATTR_##VALUE, VALUE) \
51 DEF_ATTR_TREE_LIST (ATTR_LIST_##VALUE, ATTR_NULL, \
52 ATTR_##VALUE, ATTR_NULL)
53 DEF_ATTR_FOR_INT (0)
54 DEF_ATTR_FOR_INT (1)
55 DEF_ATTR_FOR_INT (2)
56 DEF_ATTR_FOR_INT (3)
57 DEF_ATTR_FOR_INT (4)
58 DEF_ATTR_FOR_INT (5)
59 DEF_ATTR_FOR_INT (6)
60 #undef DEF_ATTR_FOR_INT
62 /* Construct a tree for a list of two integers. */
63 #define DEF_LIST_INT_INT(VALUE1, VALUE2) \
64 DEF_ATTR_TREE_LIST (ATTR_LIST_##VALUE1##_##VALUE2, ATTR_NULL, \
65 ATTR_##VALUE1, ATTR_LIST_##VALUE2)
66 DEF_LIST_INT_INT (1,0)
67 DEF_LIST_INT_INT (1,2)
68 DEF_LIST_INT_INT (2,0)
69 DEF_LIST_INT_INT (2,3)
70 DEF_LIST_INT_INT (3,0)
71 DEF_LIST_INT_INT (3,4)
72 DEF_LIST_INT_INT (4,0)
73 DEF_LIST_INT_INT (4,5)
74 DEF_LIST_INT_INT (5,0)
75 DEF_LIST_INT_INT (5,6)
76 #undef DEF_LIST_INT_INT
78 /* Construct trees for identifiers. */
79 DEF_ATTR_IDENT (ATTR_CONST, "const")
80 DEF_ATTR_IDENT (ATTR_FORMAT, "format")
81 DEF_ATTR_IDENT (ATTR_FORMAT_ARG, "format_arg")
82 DEF_ATTR_IDENT (ATTR_MALLOC, "malloc")
83 DEF_ATTR_IDENT (ATTR_NONNULL, "nonnull")
84 DEF_ATTR_IDENT (ATTR_NORETURN, "noreturn")
85 DEF_ATTR_IDENT (ATTR_NOTHROW, "nothrow")
86 DEF_ATTR_IDENT (ATTR_LEAF, "leaf")
87 DEF_ATTR_IDENT (ATTR_PRINTF, "printf")
88 DEF_ATTR_IDENT (ATTR_ASM_FPRINTF, "asm_fprintf")
89 DEF_ATTR_IDENT (ATTR_GCC_DIAG, "gcc_diag")
90 DEF_ATTR_IDENT (ATTR_GCC_CDIAG, "gcc_cdiag")
91 DEF_ATTR_IDENT (ATTR_GCC_CXXDIAG, "gcc_cxxdiag")
92 DEF_ATTR_IDENT (ATTR_PURE, "pure")
93 DEF_ATTR_IDENT (ATTR_NOVOPS, "no vops")
94 DEF_ATTR_IDENT (ATTR_SCANF, "scanf")
95 DEF_ATTR_IDENT (ATTR_SENTINEL, "sentinel")
96 DEF_ATTR_IDENT (ATTR_STRFMON, "strfmon")
97 DEF_ATTR_IDENT (ATTR_STRFTIME, "strftime")
98 DEF_ATTR_IDENT (ATTR_TYPEGENERIC, "type generic")
100 DEF_ATTR_TREE_LIST (ATTR_NOVOPS_LIST, ATTR_NOVOPS, ATTR_NULL, ATTR_NULL)
102 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)
106 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_LIST, ATTR_NOTHROW, ATTR_NULL, ATTR_NULL)
108 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_LEAF_LIST, ATTR_LEAF, ATTR_NULL, ATTR_NOTHROW_LIST)
110 DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_LIST, ATTR_CONST, \
111 ATTR_NULL, ATTR_NOTHROW_LIST)
112 DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_LEAF_LIST, ATTR_CONST, \
113 ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
114 DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_LIST, ATTR_PURE, \
115 ATTR_NULL, ATTR_NOTHROW_LIST)
116 DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_LEAF_LIST, ATTR_PURE, \
117 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, \
123 ATTR_NULL, ATTR_NOTHROW_LIST)
124 DEF_ATTR_TREE_LIST (ATTR_NORETURN_NOTHROW_LEAF_LIST, ATTR_NORETURN,\
125 ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
126 DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_LIST, ATTR_MALLOC, \
127 ATTR_NULL, ATTR_NOTHROW_LIST)
128 DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_LEAF_LIST, ATTR_MALLOC, \
129 ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
130 DEF_ATTR_TREE_LIST (ATTR_SENTINEL_NOTHROW_LIST, ATTR_SENTINEL, \
131 ATTR_NULL, ATTR_NOTHROW_LIST)
132 DEF_ATTR_TREE_LIST (ATTR_SENTINEL_NOTHROW_LEAF_LIST, ATTR_SENTINEL, \
133 ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
135 /* Functions whose pointer parameter(s) are all nonnull. */
136 DEF_ATTR_TREE_LIST (ATTR_NONNULL_LIST, ATTR_NONNULL, ATTR_NULL, ATTR_NULL)
137 /* Functions whose first parameter is a nonnull pointer. */
138 DEF_ATTR_TREE_LIST (ATTR_NONNULL_1, ATTR_NONNULL, ATTR_LIST_1, ATTR_NULL)
139 /* Functions whose second parameter is a nonnull pointer. */
140 DEF_ATTR_TREE_LIST (ATTR_NONNULL_2, ATTR_NONNULL, ATTR_LIST_2, ATTR_NULL)
141 /* Functions whose third parameter is a nonnull pointer. */
142 DEF_ATTR_TREE_LIST (ATTR_NONNULL_3, ATTR_NONNULL, ATTR_LIST_3, ATTR_NULL)
143 /* Nothrow functions with the sentinel(1) attribute. */
144 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_SENTINEL_1, ATTR_SENTINEL, ATTR_LIST_1, \
145 ATTR_NOTHROW_LIST)
146 /* Nothrow functions whose pointer parameter(s) are all nonnull. */
147 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL, ATTR_NONNULL, ATTR_NULL, \
148 ATTR_NOTHROW_LIST)
149 /* Nothrow leaf functions whose pointer parameter(s) are all nonnull. */
150 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_LEAF, ATTR_NONNULL, ATTR_NULL, \
151 ATTR_NOTHROW_LEAF_LIST)
152 /* Nothrow functions whose first parameter is a nonnull pointer. */
153 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_1, ATTR_NONNULL, ATTR_LIST_1, \
154 ATTR_NOTHROW_LIST)
155 /* Nothrow functions whose second parameter is a nonnull pointer. */
156 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_2, ATTR_NONNULL, ATTR_LIST_2, \
157 ATTR_NOTHROW_LIST)
158 /* Nothrow functions whose third parameter is a nonnull pointer. */
159 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_3, ATTR_NONNULL, ATTR_LIST_3, \
160 ATTR_NOTHROW_LIST)
161 /* Nothrow functions whose fourth parameter is a nonnull pointer. */
162 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_4, ATTR_NONNULL, ATTR_LIST_4, \
163 ATTR_NOTHROW_LIST)
164 /* Nothrow functions whose fifth parameter is a nonnull pointer. */
165 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_5, ATTR_NONNULL, ATTR_LIST_5, \
166 ATTR_NOTHROW_LIST)
167 /* Nothrow const functions whose pointer parameter(s) are all nonnull. */
168 DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_NONNULL, ATTR_CONST, ATTR_NULL, \
169 ATTR_NOTHROW_NONNULL)
170 /* 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, \
172 ATTR_NOTHROW_NONNULL_LEAF)
173 /* Nothrow const functions which are type-generic. */
174 DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_TYPEGENERIC, ATTR_TYPEGENERIC, ATTR_NULL, \
175 ATTR_CONST_NOTHROW_LIST)
176 /* Nothrow const leaf functions which are type-generic. */
177 DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF, ATTR_TYPEGENERIC, ATTR_NULL, \
178 ATTR_CONST_NOTHROW_LEAF_LIST)
179 /* Nothrow pure functions whose pointer parameter(s) are all nonnull. */
180 DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_NONNULL, ATTR_PURE, ATTR_NULL, \
181 ATTR_NOTHROW_NONNULL)
182 /* Nothrow pure leaf functions whose pointer parameter(s) are all nonnull. */
183 DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_NONNULL_LEAF, ATTR_PURE, ATTR_NULL, \
184 ATTR_NOTHROW_NONNULL_LEAF)
185 /* Nothrow malloc functions whose pointer parameter(s) are all nonnull. */
186 DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_NONNULL, ATTR_MALLOC, ATTR_NULL, \
187 ATTR_NOTHROW_NONNULL)
188 /* 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, \
190 ATTR_NOTHROW_NONNULL_LEAF)
192 /* Construct a tree for a format attribute. */
193 #define DEF_FORMAT_ATTRIBUTE(TYPE, FA, VALUES) \
194 DEF_ATTR_TREE_LIST (ATTR_##TYPE##_##VALUES, ATTR_NULL, \
195 ATTR_##TYPE, ATTR_LIST_##VALUES) \
196 DEF_ATTR_TREE_LIST (ATTR_FORMAT_##TYPE##_##VALUES, ATTR_FORMAT, \
197 ATTR_##TYPE##_##VALUES, ATTR_NONNULL_##FA)
198 #define DEF_FORMAT_ATTRIBUTE_NOTHROW(TYPE, FA, VALUES) \
199 DEF_ATTR_TREE_LIST (ATTR_##TYPE##_##VALUES, ATTR_NULL, \
200 ATTR_##TYPE, ATTR_LIST_##VALUES) \
201 DEF_ATTR_TREE_LIST (ATTR_FORMAT_##TYPE##_NOTHROW_##VALUES, ATTR_FORMAT,\
202 ATTR_##TYPE##_##VALUES, ATTR_NOTHROW_NONNULL_##FA)
203 #define DEF_FORMAT_ATTRIBUTE_BOTH(TYPE, FA, VALUES) \
204 DEF_ATTR_TREE_LIST (ATTR_##TYPE##_##VALUES, ATTR_NULL, \
205 ATTR_##TYPE, ATTR_LIST_##VALUES) \
206 DEF_ATTR_TREE_LIST (ATTR_FORMAT_##TYPE##_##VALUES, ATTR_FORMAT, \
207 ATTR_##TYPE##_##VALUES, ATTR_NONNULL_##FA) \
208 DEF_ATTR_TREE_LIST (ATTR_FORMAT_##TYPE##_NOTHROW_##VALUES, ATTR_FORMAT,\
209 ATTR_##TYPE##_##VALUES, ATTR_NOTHROW_NONNULL_##FA)
210 DEF_FORMAT_ATTRIBUTE(PRINTF,1,1_0)
211 DEF_FORMAT_ATTRIBUTE(PRINTF,1,1_2)
212 DEF_FORMAT_ATTRIBUTE_BOTH(PRINTF,2,2_0)
213 DEF_FORMAT_ATTRIBUTE_BOTH(PRINTF,2,2_3)
214 DEF_FORMAT_ATTRIBUTE_BOTH(PRINTF,3,3_0)
215 DEF_FORMAT_ATTRIBUTE_BOTH(PRINTF,3,3_4)
216 DEF_FORMAT_ATTRIBUTE_NOTHROW(PRINTF,4,4_0)
217 DEF_FORMAT_ATTRIBUTE_NOTHROW(PRINTF,4,4_5)
218 DEF_FORMAT_ATTRIBUTE_NOTHROW(PRINTF,5,5_0)
219 DEF_FORMAT_ATTRIBUTE_NOTHROW(PRINTF,5,5_6)
220 DEF_FORMAT_ATTRIBUTE(SCANF,1,1_0)
221 DEF_FORMAT_ATTRIBUTE(SCANF,1,1_2)
222 DEF_FORMAT_ATTRIBUTE_BOTH(SCANF,2,2_0)
223 DEF_FORMAT_ATTRIBUTE_BOTH(SCANF,2,2_3)
224 DEF_FORMAT_ATTRIBUTE_NOTHROW(STRFTIME,3,3_0)
225 DEF_FORMAT_ATTRIBUTE_NOTHROW(STRFMON,3,3_4)
226 #undef DEF_FORMAT_ATTRIBUTE
227 #undef DEF_FORMAT_ATTRIBUTE_NOTHROW
228 #undef DEF_FORMAT_ATTRIBUTE_BOTH
230 /* Construct a tree for a format_arg attribute. */
231 #define DEF_FORMAT_ARG_ATTRIBUTE(FA) \
232 DEF_ATTR_TREE_LIST (ATTR_FORMAT_ARG_##FA, ATTR_FORMAT_ARG, \
233 ATTR_LIST_##FA, ATTR_NOTHROW_NONNULL_##FA)
234 DEF_FORMAT_ARG_ATTRIBUTE(1)
235 DEF_FORMAT_ARG_ATTRIBUTE(2)
236 #undef DEF_FORMAT_ARG_ATTRIBUTE