]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/builtin-attrs.def
decl.c (components_to_record): Adjust the packedness for the qualified union as well.
[thirdparty/gcc.git] / gcc / builtin-attrs.def
CommitLineData
9dcd6f09 1/* Copyright (C) 2001, 2002, 2004, 2005, 2007 Free Software Foundation, Inc.
6431177a
JM
2 Contributed by Joseph Myers <jsm28@cam.ac.uk>.
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
9dcd6f09 8Software Foundation; either version 3, or (at your option) any later
6431177a
JM
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16You should have received a copy of the GNU General Public License
9dcd6f09
NC
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
6431177a
JM
19
20/* This header provides a declarative way of describing the attributes
21 that are applied to some functions by default.
22
23 Before including this header, you must define the following macros.
24 In each case where there is an ENUM, it is an identifier used to
25 reference the tree in subsequent definitions.
26
27 DEF_ATTR_NULL_TREE (ENUM)
28
29 Constructs a NULL_TREE.
30
31 DEF_ATTR_INT (ENUM, VALUE)
32
33 Constructs an INTEGER_CST with value VALUE (an integer representable
34 in HOST_WIDE_INT).
35
36 DEF_ATTR_IDENT (ENUM, STRING)
37
38 Constructs an IDENTIFIER_NODE for STRING.
39
40 DEF_ATTR_TREE_LIST (ENUM, PURPOSE, VALUE, CHAIN)
41
42 Constructs a TREE_LIST with given PURPOSE, VALUE and CHAIN (given
178b2b9f 43 as previous ENUM names). */
6431177a
JM
44
45DEF_ATTR_NULL_TREE (ATTR_NULL)
46
6431177a
JM
47/* Construct a tree for a given integer and a list containing it. */
48#define DEF_ATTR_FOR_INT(VALUE) \
9a238586
KG
49 DEF_ATTR_INT (ATTR_##VALUE, VALUE) \
50 DEF_ATTR_TREE_LIST (ATTR_LIST_##VALUE, ATTR_NULL, \
51 ATTR_##VALUE, ATTR_NULL)
6431177a
JM
52DEF_ATTR_FOR_INT (0)
53DEF_ATTR_FOR_INT (1)
54DEF_ATTR_FOR_INT (2)
55DEF_ATTR_FOR_INT (3)
56DEF_ATTR_FOR_INT (4)
10a0d495
JJ
57DEF_ATTR_FOR_INT (5)
58DEF_ATTR_FOR_INT (6)
6431177a
JM
59#undef DEF_ATTR_FOR_INT
60
61/* Construct a tree for a list of two integers. */
62#define DEF_LIST_INT_INT(VALUE1, VALUE2) \
9a238586
KG
63 DEF_ATTR_TREE_LIST (ATTR_LIST_##VALUE1##_##VALUE2, ATTR_NULL, \
64 ATTR_##VALUE1, ATTR_LIST_##VALUE2)
6431177a
JM
65DEF_LIST_INT_INT (1,0)
66DEF_LIST_INT_INT (1,2)
67DEF_LIST_INT_INT (2,0)
68DEF_LIST_INT_INT (2,3)
69DEF_LIST_INT_INT (3,0)
70DEF_LIST_INT_INT (3,4)
10a0d495
JJ
71DEF_LIST_INT_INT (4,0)
72DEF_LIST_INT_INT (4,5)
73DEF_LIST_INT_INT (5,0)
74DEF_LIST_INT_INT (5,6)
6431177a
JM
75#undef DEF_LIST_INT_INT
76
c72c42e8 77/* Construct trees for identifiers. */
df061a43
RS
78DEF_ATTR_IDENT (ATTR_CONST, "const")
79DEF_ATTR_IDENT (ATTR_FORMAT, "format")
80DEF_ATTR_IDENT (ATTR_FORMAT_ARG, "format_arg")
81DEF_ATTR_IDENT (ATTR_MALLOC, "malloc")
82DEF_ATTR_IDENT (ATTR_NONNULL, "nonnull")
83DEF_ATTR_IDENT (ATTR_NORETURN, "noreturn")
84DEF_ATTR_IDENT (ATTR_NOTHROW, "nothrow")
6431177a 85DEF_ATTR_IDENT (ATTR_PRINTF, "printf")
3ae1d4c2 86DEF_ATTR_IDENT (ATTR_ASM_FPRINTF, "asm_fprintf")
280c1e0d
KG
87DEF_ATTR_IDENT (ATTR_GCC_DIAG, "gcc_diag")
88DEF_ATTR_IDENT (ATTR_GCC_CDIAG, "gcc_cdiag")
89DEF_ATTR_IDENT (ATTR_GCC_CXXDIAG, "gcc_cxxdiag")
df061a43 90DEF_ATTR_IDENT (ATTR_PURE, "pure")
dcd6de6d 91DEF_ATTR_IDENT (ATTR_NOVOPS, "no vops")
6431177a 92DEF_ATTR_IDENT (ATTR_SCANF, "scanf")
3d091dac 93DEF_ATTR_IDENT (ATTR_SENTINEL, "sentinel")
6431177a 94DEF_ATTR_IDENT (ATTR_STRFMON, "strfmon")
df061a43 95DEF_ATTR_IDENT (ATTR_STRFTIME, "strftime")
b5d32c25 96DEF_ATTR_IDENT (ATTR_TYPEGENERIC, "type generic")
6431177a 97
dcd6de6d
ZD
98DEF_ATTR_TREE_LIST (ATTR_NOVOPS_LIST, ATTR_NOVOPS, ATTR_NULL, ATTR_NULL)
99
df061a43 100DEF_ATTR_TREE_LIST (ATTR_NOTHROW_LIST, ATTR_NOTHROW, ATTR_NULL, ATTR_NULL)
6431177a 101
df061a43
RS
102DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_LIST, ATTR_CONST, \
103 ATTR_NULL, ATTR_NOTHROW_LIST)
104DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_LIST, ATTR_PURE, \
105 ATTR_NULL, ATTR_NOTHROW_LIST)
dcd6de6d
ZD
106DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_NOVOPS_LIST, ATTR_NOVOPS, \
107 ATTR_NULL, ATTR_PURE_NOTHROW_LIST)
df061a43
RS
108DEF_ATTR_TREE_LIST (ATTR_NORETURN_NOTHROW_LIST, ATTR_NORETURN, \
109 ATTR_NULL, ATTR_NOTHROW_LIST)
110DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_LIST, ATTR_MALLOC, \
111 ATTR_NULL, ATTR_NOTHROW_LIST)
3d091dac
KG
112DEF_ATTR_TREE_LIST (ATTR_SENTINEL_NOTHROW_LIST, ATTR_SENTINEL, \
113 ATTR_NULL, ATTR_NOTHROW_LIST)
79ed7328 114
74124c73
KG
115/* Functions whose pointer parameter(s) are all nonnull. */
116DEF_ATTR_TREE_LIST (ATTR_NONNULL_LIST, ATTR_NONNULL, ATTR_NULL, ATTR_NULL)
117/* Functions whose first parameter is a nonnull pointer. */
0d5b215c 118DEF_ATTR_TREE_LIST (ATTR_NONNULL_1, ATTR_NONNULL, ATTR_LIST_1, ATTR_NULL)
74124c73 119/* Functions whose second parameter is a nonnull pointer. */
0d5b215c 120DEF_ATTR_TREE_LIST (ATTR_NONNULL_2, ATTR_NONNULL, ATTR_LIST_2, ATTR_NULL)
b1e3f20e
JJ
121/* Functions whose third parameter is a nonnull pointer. */
122DEF_ATTR_TREE_LIST (ATTR_NONNULL_3, ATTR_NONNULL, ATTR_LIST_3, ATTR_NULL)
74124c73 123/* Nothrow functions with the sentinel(1) attribute. */
254986c7
KG
124DEF_ATTR_TREE_LIST (ATTR_NOTHROW_SENTINEL_1, ATTR_SENTINEL, ATTR_LIST_1, \
125 ATTR_NOTHROW_LIST)
74124c73
KG
126/* Nothrow functions whose pointer parameter(s) are all nonnull. */
127DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL, ATTR_NONNULL, ATTR_NULL, \
128 ATTR_NOTHROW_LIST)
129/* Nothrow functions whose first parameter is a nonnull pointer. */
00362064 130DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_1, ATTR_NONNULL, ATTR_LIST_1, \
08291658 131 ATTR_NOTHROW_LIST)
74124c73 132/* Nothrow functions whose second parameter is a nonnull pointer. */
00362064 133DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_2, ATTR_NONNULL, ATTR_LIST_2, \
08291658 134 ATTR_NOTHROW_LIST)
74124c73 135/* Nothrow functions whose third parameter is a nonnull pointer. */
00362064 136DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_3, ATTR_NONNULL, ATTR_LIST_3, \
08291658 137 ATTR_NOTHROW_LIST)
10a0d495
JJ
138/* Nothrow functions whose fourth parameter is a nonnull pointer. */
139DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_4, ATTR_NONNULL, ATTR_LIST_4, \
140 ATTR_NOTHROW_LIST)
141/* Nothrow functions whose fifth parameter is a nonnull pointer. */
142DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_5, ATTR_NONNULL, ATTR_LIST_5, \
143 ATTR_NOTHROW_LIST)
74124c73
KG
144/* Nothrow const functions whose pointer parameter(s) are all nonnull. */
145DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_NONNULL, ATTR_CONST, ATTR_NULL, \
146 ATTR_NOTHROW_NONNULL)
b5d32c25
KG
147/* Nothrow const functions which are type-generic. */
148DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_TYPEGENERIC, ATTR_TYPEGENERIC, ATTR_NULL, \
149 ATTR_CONST_NOTHROW_LIST)
74124c73
KG
150/* Nothrow pure functions whose pointer parameter(s) are all nonnull. */
151DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_NONNULL, ATTR_PURE, ATTR_NULL, \
152 ATTR_NOTHROW_NONNULL)
153/* Nothrow malloc functions whose pointer parameter(s) are all nonnull. */
154DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_NONNULL, ATTR_MALLOC, ATTR_NULL, \
155 ATTR_NOTHROW_NONNULL)
79ed7328 156
6431177a 157/* Construct a tree for a format attribute. */
79ed7328 158#define DEF_FORMAT_ATTRIBUTE(TYPE, FA, VALUES) \
9a238586
KG
159 DEF_ATTR_TREE_LIST (ATTR_##TYPE##_##VALUES, ATTR_NULL, \
160 ATTR_##TYPE, ATTR_LIST_##VALUES) \
161 DEF_ATTR_TREE_LIST (ATTR_FORMAT_##TYPE##_##VALUES, ATTR_FORMAT, \
b1e3f20e
JJ
162 ATTR_##TYPE##_##VALUES, ATTR_NONNULL_##FA)
163#define DEF_FORMAT_ATTRIBUTE_NOTHROW(TYPE, FA, VALUES) \
164 DEF_ATTR_TREE_LIST (ATTR_##TYPE##_##VALUES, ATTR_NULL, \
165 ATTR_##TYPE, ATTR_LIST_##VALUES) \
166 DEF_ATTR_TREE_LIST (ATTR_FORMAT_##TYPE##_NOTHROW_##VALUES, ATTR_FORMAT,\
167 ATTR_##TYPE##_##VALUES, ATTR_NOTHROW_NONNULL_##FA)
168#define DEF_FORMAT_ATTRIBUTE_BOTH(TYPE, FA, VALUES) \
169 DEF_ATTR_TREE_LIST (ATTR_##TYPE##_##VALUES, ATTR_NULL, \
170 ATTR_##TYPE, ATTR_LIST_##VALUES) \
171 DEF_ATTR_TREE_LIST (ATTR_FORMAT_##TYPE##_##VALUES, ATTR_FORMAT, \
172 ATTR_##TYPE##_##VALUES, ATTR_NONNULL_##FA) \
173 DEF_ATTR_TREE_LIST (ATTR_FORMAT_##TYPE##_NOTHROW_##VALUES, ATTR_FORMAT,\
9a238586 174 ATTR_##TYPE##_##VALUES, ATTR_NOTHROW_NONNULL_##FA)
79ed7328
JT
175DEF_FORMAT_ATTRIBUTE(PRINTF,1,1_0)
176DEF_FORMAT_ATTRIBUTE(PRINTF,1,1_2)
b1e3f20e
JJ
177DEF_FORMAT_ATTRIBUTE_BOTH(PRINTF,2,2_0)
178DEF_FORMAT_ATTRIBUTE_BOTH(PRINTF,2,2_3)
179DEF_FORMAT_ATTRIBUTE_BOTH(PRINTF,3,3_0)
180DEF_FORMAT_ATTRIBUTE_BOTH(PRINTF,3,3_4)
181DEF_FORMAT_ATTRIBUTE_NOTHROW(PRINTF,4,4_0)
182DEF_FORMAT_ATTRIBUTE_NOTHROW(PRINTF,4,4_5)
183DEF_FORMAT_ATTRIBUTE_NOTHROW(PRINTF,5,5_0)
184DEF_FORMAT_ATTRIBUTE_NOTHROW(PRINTF,5,5_6)
79ed7328
JT
185DEF_FORMAT_ATTRIBUTE(SCANF,1,1_0)
186DEF_FORMAT_ATTRIBUTE(SCANF,1,1_2)
b1e3f20e
JJ
187DEF_FORMAT_ATTRIBUTE_BOTH(SCANF,2,2_0)
188DEF_FORMAT_ATTRIBUTE_BOTH(SCANF,2,2_3)
189DEF_FORMAT_ATTRIBUTE_NOTHROW(STRFTIME,3,3_0)
190DEF_FORMAT_ATTRIBUTE_NOTHROW(STRFMON,3,3_4)
6431177a 191#undef DEF_FORMAT_ATTRIBUTE
b1e3f20e
JJ
192#undef DEF_FORMAT_ATTRIBUTE_NOTHROW
193#undef DEF_FORMAT_ATTRIBUTE_BOTH
6431177a 194
79ed7328
JT
195/* Construct a tree for a format_arg attribute. */
196#define DEF_FORMAT_ARG_ATTRIBUTE(FA) \
9a238586
KG
197 DEF_ATTR_TREE_LIST (ATTR_FORMAT_ARG_##FA, ATTR_FORMAT_ARG, \
198 ATTR_LIST_##FA, ATTR_NOTHROW_NONNULL_##FA)
79ed7328
JT
199DEF_FORMAT_ARG_ATTRIBUTE(1)
200DEF_FORMAT_ARG_ATTRIBUTE(2)
201#undef DEF_FORMAT_ARG_ATTRIBUTE
6431177a 202