]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/builtin-attrs.def
Mark transaction begin as returns-twice.
[thirdparty/gcc.git] / gcc / builtin-attrs.def
CommitLineData
d652f226
JJ
1/* Copyright (C) 2001, 2002, 2004, 2005, 2007, 2010
2 Free Software Foundation, Inc.
6431177a
JM
3 Contributed by Joseph Myers <jsm28@cam.ac.uk>.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9dcd6f09 9Software Foundation; either version 3, or (at your option) any later
6431177a
JM
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
9dcd6f09
NC
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
6431177a
JM
20
21/* This header provides a declarative way of describing the attributes
22 that are applied to some functions by default.
23
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.
27
28 DEF_ATTR_NULL_TREE (ENUM)
29
30 Constructs a NULL_TREE.
31
32 DEF_ATTR_INT (ENUM, VALUE)
33
34 Constructs an INTEGER_CST with value VALUE (an integer representable
35 in HOST_WIDE_INT).
36
37 DEF_ATTR_IDENT (ENUM, STRING)
38
39 Constructs an IDENTIFIER_NODE for STRING.
40
41 DEF_ATTR_TREE_LIST (ENUM, PURPOSE, VALUE, CHAIN)
42
43 Constructs a TREE_LIST with given PURPOSE, VALUE and CHAIN (given
178b2b9f 44 as previous ENUM names). */
6431177a
JM
45
46DEF_ATTR_NULL_TREE (ATTR_NULL)
47
6431177a
JM
48/* Construct a tree for a given integer and a list containing it. */
49#define DEF_ATTR_FOR_INT(VALUE) \
9a238586
KG
50 DEF_ATTR_INT (ATTR_##VALUE, VALUE) \
51 DEF_ATTR_TREE_LIST (ATTR_LIST_##VALUE, ATTR_NULL, \
52 ATTR_##VALUE, ATTR_NULL)
6431177a
JM
53DEF_ATTR_FOR_INT (0)
54DEF_ATTR_FOR_INT (1)
55DEF_ATTR_FOR_INT (2)
56DEF_ATTR_FOR_INT (3)
57DEF_ATTR_FOR_INT (4)
10a0d495
JJ
58DEF_ATTR_FOR_INT (5)
59DEF_ATTR_FOR_INT (6)
6431177a
JM
60#undef DEF_ATTR_FOR_INT
61
62/* Construct a tree for a list of two integers. */
63#define DEF_LIST_INT_INT(VALUE1, VALUE2) \
9a238586
KG
64 DEF_ATTR_TREE_LIST (ATTR_LIST_##VALUE1##_##VALUE2, ATTR_NULL, \
65 ATTR_##VALUE1, ATTR_LIST_##VALUE2)
6431177a
JM
66DEF_LIST_INT_INT (1,0)
67DEF_LIST_INT_INT (1,2)
68DEF_LIST_INT_INT (2,0)
69DEF_LIST_INT_INT (2,3)
70DEF_LIST_INT_INT (3,0)
71DEF_LIST_INT_INT (3,4)
10a0d495
JJ
72DEF_LIST_INT_INT (4,0)
73DEF_LIST_INT_INT (4,5)
74DEF_LIST_INT_INT (5,0)
75DEF_LIST_INT_INT (5,6)
6431177a
JM
76#undef DEF_LIST_INT_INT
77
c72c42e8 78/* Construct trees for identifiers. */
df061a43
RS
79DEF_ATTR_IDENT (ATTR_CONST, "const")
80DEF_ATTR_IDENT (ATTR_FORMAT, "format")
81DEF_ATTR_IDENT (ATTR_FORMAT_ARG, "format_arg")
82DEF_ATTR_IDENT (ATTR_MALLOC, "malloc")
83DEF_ATTR_IDENT (ATTR_NONNULL, "nonnull")
84DEF_ATTR_IDENT (ATTR_NORETURN, "noreturn")
85DEF_ATTR_IDENT (ATTR_NOTHROW, "nothrow")
0d6e14fd 86DEF_ATTR_IDENT (ATTR_LEAF, "leaf")
6431177a 87DEF_ATTR_IDENT (ATTR_PRINTF, "printf")
3ae1d4c2 88DEF_ATTR_IDENT (ATTR_ASM_FPRINTF, "asm_fprintf")
280c1e0d
KG
89DEF_ATTR_IDENT (ATTR_GCC_DIAG, "gcc_diag")
90DEF_ATTR_IDENT (ATTR_GCC_CDIAG, "gcc_cdiag")
91DEF_ATTR_IDENT (ATTR_GCC_CXXDIAG, "gcc_cxxdiag")
df061a43 92DEF_ATTR_IDENT (ATTR_PURE, "pure")
dcd6de6d 93DEF_ATTR_IDENT (ATTR_NOVOPS, "no vops")
6431177a 94DEF_ATTR_IDENT (ATTR_SCANF, "scanf")
3d091dac 95DEF_ATTR_IDENT (ATTR_SENTINEL, "sentinel")
6431177a 96DEF_ATTR_IDENT (ATTR_STRFMON, "strfmon")
df061a43 97DEF_ATTR_IDENT (ATTR_STRFTIME, "strftime")
b5d32c25 98DEF_ATTR_IDENT (ATTR_TYPEGENERIC, "type generic")
0a35513e
AH
99DEF_ATTR_IDENT (ATTR_TM_REGPARM, "*tm regparm")
100DEF_ATTR_IDENT (ATTR_TM_TMPURE, "transaction_pure")
b0c99997 101DEF_ATTR_IDENT (ATTR_RETURNS_TWICE, "returns_twice")
6431177a 102
dcd6de6d
ZD
103DEF_ATTR_TREE_LIST (ATTR_NOVOPS_LIST, ATTR_NOVOPS, ATTR_NULL, ATTR_NULL)
104
0d6e14fd
JH
105DEF_ATTR_TREE_LIST (ATTR_NOVOPS_LEAF_LIST, ATTR_LEAF, ATTR_NULL, ATTR_NOVOPS_LIST)
106
107DEF_ATTR_TREE_LIST (ATTR_LEAF_LIST, ATTR_LEAF, ATTR_NULL, ATTR_NULL)
108
df061a43 109DEF_ATTR_TREE_LIST (ATTR_NOTHROW_LIST, ATTR_NOTHROW, ATTR_NULL, ATTR_NULL)
6431177a 110
0d6e14fd
JH
111DEF_ATTR_TREE_LIST (ATTR_NOTHROW_LEAF_LIST, ATTR_LEAF, ATTR_NULL, ATTR_NOTHROW_LIST)
112
df061a43
RS
113DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_LIST, ATTR_CONST, \
114 ATTR_NULL, ATTR_NOTHROW_LIST)
0d6e14fd
JH
115DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_LEAF_LIST, ATTR_CONST, \
116 ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
df061a43
RS
117DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_LIST, ATTR_PURE, \
118 ATTR_NULL, ATTR_NOTHROW_LIST)
0d6e14fd
JH
119DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_LEAF_LIST, ATTR_PURE, \
120 ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
dcd6de6d
ZD
121DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_NOVOPS_LIST, ATTR_NOVOPS, \
122 ATTR_NULL, ATTR_PURE_NOTHROW_LIST)
0d6e14fd
JH
123DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_NOVOPS_LEAF_LIST, ATTR_NOVOPS,\
124 ATTR_NULL, ATTR_PURE_NOTHROW_LEAF_LIST)
df061a43
RS
125DEF_ATTR_TREE_LIST (ATTR_NORETURN_NOTHROW_LIST, ATTR_NORETURN, \
126 ATTR_NULL, ATTR_NOTHROW_LIST)
0d6e14fd
JH
127DEF_ATTR_TREE_LIST (ATTR_NORETURN_NOTHROW_LEAF_LIST, ATTR_NORETURN,\
128 ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
df061a43
RS
129DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_LIST, ATTR_MALLOC, \
130 ATTR_NULL, ATTR_NOTHROW_LIST)
0d6e14fd
JH
131DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_LEAF_LIST, ATTR_MALLOC, \
132 ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
3d091dac
KG
133DEF_ATTR_TREE_LIST (ATTR_SENTINEL_NOTHROW_LIST, ATTR_SENTINEL, \
134 ATTR_NULL, ATTR_NOTHROW_LIST)
0d6e14fd
JH
135DEF_ATTR_TREE_LIST (ATTR_SENTINEL_NOTHROW_LEAF_LIST, ATTR_SENTINEL, \
136 ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
79ed7328 137
74124c73
KG
138/* Functions whose pointer parameter(s) are all nonnull. */
139DEF_ATTR_TREE_LIST (ATTR_NONNULL_LIST, ATTR_NONNULL, ATTR_NULL, ATTR_NULL)
140/* Functions whose first parameter is a nonnull pointer. */
0d5b215c 141DEF_ATTR_TREE_LIST (ATTR_NONNULL_1, ATTR_NONNULL, ATTR_LIST_1, ATTR_NULL)
74124c73 142/* Functions whose second parameter is a nonnull pointer. */
0d5b215c 143DEF_ATTR_TREE_LIST (ATTR_NONNULL_2, ATTR_NONNULL, ATTR_LIST_2, ATTR_NULL)
b1e3f20e
JJ
144/* Functions whose third parameter is a nonnull pointer. */
145DEF_ATTR_TREE_LIST (ATTR_NONNULL_3, ATTR_NONNULL, ATTR_LIST_3, ATTR_NULL)
74124c73 146/* Nothrow functions with the sentinel(1) attribute. */
254986c7
KG
147DEF_ATTR_TREE_LIST (ATTR_NOTHROW_SENTINEL_1, ATTR_SENTINEL, ATTR_LIST_1, \
148 ATTR_NOTHROW_LIST)
74124c73
KG
149/* Nothrow functions whose pointer parameter(s) are all nonnull. */
150DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL, ATTR_NONNULL, ATTR_NULL, \
151 ATTR_NOTHROW_LIST)
0d6e14fd
JH
152/* Nothrow leaf functions whose pointer parameter(s) are all nonnull. */
153DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_LEAF, ATTR_NONNULL, ATTR_NULL, \
154 ATTR_NOTHROW_LEAF_LIST)
74124c73 155/* Nothrow functions whose first parameter is a nonnull pointer. */
00362064 156DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_1, ATTR_NONNULL, ATTR_LIST_1, \
08291658 157 ATTR_NOTHROW_LIST)
74124c73 158/* Nothrow functions whose second parameter is a nonnull pointer. */
00362064 159DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_2, ATTR_NONNULL, ATTR_LIST_2, \
08291658 160 ATTR_NOTHROW_LIST)
74124c73 161/* Nothrow functions whose third parameter is a nonnull pointer. */
00362064 162DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_3, ATTR_NONNULL, ATTR_LIST_3, \
08291658 163 ATTR_NOTHROW_LIST)
10a0d495
JJ
164/* Nothrow functions whose fourth parameter is a nonnull pointer. */
165DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_4, ATTR_NONNULL, ATTR_LIST_4, \
166 ATTR_NOTHROW_LIST)
167/* Nothrow functions whose fifth parameter is a nonnull pointer. */
168DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_5, ATTR_NONNULL, ATTR_LIST_5, \
169 ATTR_NOTHROW_LIST)
74124c73
KG
170/* Nothrow const functions whose pointer parameter(s) are all nonnull. */
171DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_NONNULL, ATTR_CONST, ATTR_NULL, \
172 ATTR_NOTHROW_NONNULL)
0d6e14fd
JH
173/* Nothrow const leaf functions whose pointer parameter(s) are all nonnull. */
174DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_NONNULL_LEAF, ATTR_CONST, ATTR_NULL, \
175 ATTR_NOTHROW_NONNULL_LEAF)
b5d32c25
KG
176/* Nothrow const functions which are type-generic. */
177DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_TYPEGENERIC, ATTR_TYPEGENERIC, ATTR_NULL, \
178 ATTR_CONST_NOTHROW_LIST)
0d6e14fd
JH
179/* Nothrow const leaf functions which are type-generic. */
180DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF, ATTR_TYPEGENERIC, ATTR_NULL, \
181 ATTR_CONST_NOTHROW_LEAF_LIST)
74124c73
KG
182/* Nothrow pure functions whose pointer parameter(s) are all nonnull. */
183DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_NONNULL, ATTR_PURE, ATTR_NULL, \
184 ATTR_NOTHROW_NONNULL)
0d6e14fd
JH
185/* Nothrow pure leaf functions whose pointer parameter(s) are all nonnull. */
186DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_NONNULL_LEAF, ATTR_PURE, ATTR_NULL, \
187 ATTR_NOTHROW_NONNULL_LEAF)
74124c73
KG
188/* Nothrow malloc functions whose pointer parameter(s) are all nonnull. */
189DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_NONNULL, ATTR_MALLOC, ATTR_NULL, \
190 ATTR_NOTHROW_NONNULL)
0d6e14fd
JH
191/* Nothrow malloc leaf functions whose pointer parameter(s) are all nonnull. */
192DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_NONNULL_LEAF, ATTR_MALLOC, ATTR_NULL, \
193 ATTR_NOTHROW_NONNULL_LEAF)
79ed7328 194
6431177a 195/* Construct a tree for a format attribute. */
79ed7328 196#define DEF_FORMAT_ATTRIBUTE(TYPE, FA, VALUES) \
9a238586
KG
197 DEF_ATTR_TREE_LIST (ATTR_##TYPE##_##VALUES, ATTR_NULL, \
198 ATTR_##TYPE, ATTR_LIST_##VALUES) \
199 DEF_ATTR_TREE_LIST (ATTR_FORMAT_##TYPE##_##VALUES, ATTR_FORMAT, \
b1e3f20e
JJ
200 ATTR_##TYPE##_##VALUES, ATTR_NONNULL_##FA)
201#define DEF_FORMAT_ATTRIBUTE_NOTHROW(TYPE, FA, VALUES) \
202 DEF_ATTR_TREE_LIST (ATTR_##TYPE##_##VALUES, ATTR_NULL, \
203 ATTR_##TYPE, ATTR_LIST_##VALUES) \
204 DEF_ATTR_TREE_LIST (ATTR_FORMAT_##TYPE##_NOTHROW_##VALUES, ATTR_FORMAT,\
205 ATTR_##TYPE##_##VALUES, ATTR_NOTHROW_NONNULL_##FA)
206#define DEF_FORMAT_ATTRIBUTE_BOTH(TYPE, FA, VALUES) \
207 DEF_ATTR_TREE_LIST (ATTR_##TYPE##_##VALUES, ATTR_NULL, \
208 ATTR_##TYPE, ATTR_LIST_##VALUES) \
209 DEF_ATTR_TREE_LIST (ATTR_FORMAT_##TYPE##_##VALUES, ATTR_FORMAT, \
210 ATTR_##TYPE##_##VALUES, ATTR_NONNULL_##FA) \
211 DEF_ATTR_TREE_LIST (ATTR_FORMAT_##TYPE##_NOTHROW_##VALUES, ATTR_FORMAT,\
9a238586 212 ATTR_##TYPE##_##VALUES, ATTR_NOTHROW_NONNULL_##FA)
79ed7328
JT
213DEF_FORMAT_ATTRIBUTE(PRINTF,1,1_0)
214DEF_FORMAT_ATTRIBUTE(PRINTF,1,1_2)
b1e3f20e
JJ
215DEF_FORMAT_ATTRIBUTE_BOTH(PRINTF,2,2_0)
216DEF_FORMAT_ATTRIBUTE_BOTH(PRINTF,2,2_3)
217DEF_FORMAT_ATTRIBUTE_BOTH(PRINTF,3,3_0)
218DEF_FORMAT_ATTRIBUTE_BOTH(PRINTF,3,3_4)
219DEF_FORMAT_ATTRIBUTE_NOTHROW(PRINTF,4,4_0)
220DEF_FORMAT_ATTRIBUTE_NOTHROW(PRINTF,4,4_5)
221DEF_FORMAT_ATTRIBUTE_NOTHROW(PRINTF,5,5_0)
222DEF_FORMAT_ATTRIBUTE_NOTHROW(PRINTF,5,5_6)
79ed7328
JT
223DEF_FORMAT_ATTRIBUTE(SCANF,1,1_0)
224DEF_FORMAT_ATTRIBUTE(SCANF,1,1_2)
b1e3f20e
JJ
225DEF_FORMAT_ATTRIBUTE_BOTH(SCANF,2,2_0)
226DEF_FORMAT_ATTRIBUTE_BOTH(SCANF,2,2_3)
227DEF_FORMAT_ATTRIBUTE_NOTHROW(STRFTIME,3,3_0)
228DEF_FORMAT_ATTRIBUTE_NOTHROW(STRFMON,3,3_4)
6431177a 229#undef DEF_FORMAT_ATTRIBUTE
b1e3f20e
JJ
230#undef DEF_FORMAT_ATTRIBUTE_NOTHROW
231#undef DEF_FORMAT_ATTRIBUTE_BOTH
6431177a 232
0a35513e
AH
233/* Transactional memory variants of the above. */
234
235DEF_ATTR_TREE_LIST (ATTR_TM_NOTHROW_LIST,
236 ATTR_TM_REGPARM, ATTR_NULL, ATTR_NOTHROW_LIST)
237DEF_ATTR_TREE_LIST (ATTR_TM_TMPURE_NOTHROW_LIST,
238 ATTR_TM_TMPURE, ATTR_NULL, ATTR_TM_NOTHROW_LIST)
239DEF_ATTR_TREE_LIST (ATTR_TM_PURE_TMPURE_NOTHROW_LIST,
240 ATTR_PURE, ATTR_NULL, ATTR_TM_TMPURE_NOTHROW_LIST)
241DEF_ATTR_TREE_LIST (ATTR_TM_NORETURN_NOTHROW_LIST,
242 ATTR_TM_REGPARM, ATTR_NULL, ATTR_NORETURN_NOTHROW_LIST)
243DEF_ATTR_TREE_LIST (ATTR_TM_CONST_NOTHROW_LIST,
244 ATTR_TM_REGPARM, ATTR_NULL, ATTR_CONST_NOTHROW_LIST)
b0c99997
TR
245DEF_ATTR_TREE_LIST (ATTR_TM_NOTHROW_RT_LIST,
246 ATTR_RETURNS_TWICE, ATTR_NULL, ATTR_TM_NOTHROW_LIST)
0a35513e
AH
247
248/* Same attributes used for BUILT_IN_MALLOC except with TM_PURE thrown in. */
249DEF_ATTR_TREE_LIST (ATTR_TMPURE_MALLOC_NOTHROW_LIST,
250 ATTR_TM_TMPURE, ATTR_NULL, ATTR_MALLOC_NOTHROW_LIST)
251/* Same attributes used for BUILT_IN_FREE except with TM_PURE thrown in. */
252DEF_ATTR_TREE_LIST (ATTR_TMPURE_NOTHROW_LIST,
253 ATTR_TM_TMPURE, ATTR_NULL, ATTR_NOTHROW_LIST)
254
79ed7328
JT
255/* Construct a tree for a format_arg attribute. */
256#define DEF_FORMAT_ARG_ATTRIBUTE(FA) \
9a238586
KG
257 DEF_ATTR_TREE_LIST (ATTR_FORMAT_ARG_##FA, ATTR_FORMAT_ARG, \
258 ATTR_LIST_##FA, ATTR_NOTHROW_NONNULL_##FA)
79ed7328
JT
259DEF_FORMAT_ARG_ATTRIBUTE(1)
260DEF_FORMAT_ARG_ATTRIBUTE(2)
261#undef DEF_FORMAT_ARG_ATTRIBUTE
6431177a 262