]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/builtin-attrs.def
gcc_release (announce_snapshot): Use changedir instead of plain cd.
[thirdparty/gcc.git] / gcc / builtin-attrs.def
CommitLineData
79ed7328 1/* Copyright (C) 2001, 2002 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
8Software Foundation; either version 2, or (at your option) any later
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
17along with GCC; see the file COPYING. If not, write to the Free
18Software Foundation, 59 Temple Place - Suite 330, Boston, MA
1902111-1307, USA. */
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)
58#undef DEF_ATTR_FOR_INT
59
60/* Construct a tree for a list of two integers. */
61#define DEF_LIST_INT_INT(VALUE1, VALUE2) \
9a238586
KG
62 DEF_ATTR_TREE_LIST (ATTR_LIST_##VALUE1##_##VALUE2, ATTR_NULL, \
63 ATTR_##VALUE1, ATTR_LIST_##VALUE2)
6431177a
JM
64DEF_LIST_INT_INT (1,0)
65DEF_LIST_INT_INT (1,2)
66DEF_LIST_INT_INT (2,0)
67DEF_LIST_INT_INT (2,3)
68DEF_LIST_INT_INT (3,0)
69DEF_LIST_INT_INT (3,4)
70#undef DEF_LIST_INT_INT
71
df061a43
RS
72/* Construct tress for identifiers. */
73DEF_ATTR_IDENT (ATTR_CONST, "const")
74DEF_ATTR_IDENT (ATTR_FORMAT, "format")
75DEF_ATTR_IDENT (ATTR_FORMAT_ARG, "format_arg")
76DEF_ATTR_IDENT (ATTR_MALLOC, "malloc")
77DEF_ATTR_IDENT (ATTR_NONNULL, "nonnull")
78DEF_ATTR_IDENT (ATTR_NORETURN, "noreturn")
79DEF_ATTR_IDENT (ATTR_NOTHROW, "nothrow")
6431177a 80DEF_ATTR_IDENT (ATTR_PRINTF, "printf")
3ae1d4c2 81DEF_ATTR_IDENT (ATTR_ASM_FPRINTF, "asm_fprintf")
280c1e0d
KG
82DEF_ATTR_IDENT (ATTR_GCC_DIAG, "gcc_diag")
83DEF_ATTR_IDENT (ATTR_GCC_CDIAG, "gcc_cdiag")
84DEF_ATTR_IDENT (ATTR_GCC_CXXDIAG, "gcc_cxxdiag")
df061a43 85DEF_ATTR_IDENT (ATTR_PURE, "pure")
6431177a 86DEF_ATTR_IDENT (ATTR_SCANF, "scanf")
6431177a 87DEF_ATTR_IDENT (ATTR_STRFMON, "strfmon")
df061a43 88DEF_ATTR_IDENT (ATTR_STRFTIME, "strftime")
6431177a 89
df061a43 90DEF_ATTR_TREE_LIST (ATTR_NOTHROW_LIST, ATTR_NOTHROW, ATTR_NULL, ATTR_NULL)
6431177a 91
df061a43
RS
92DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_LIST, ATTR_CONST, \
93 ATTR_NULL, ATTR_NOTHROW_LIST)
94DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_LIST, ATTR_PURE, \
95 ATTR_NULL, ATTR_NOTHROW_LIST)
96DEF_ATTR_TREE_LIST (ATTR_NORETURN_NOTHROW_LIST, ATTR_NORETURN, \
97 ATTR_NULL, ATTR_NOTHROW_LIST)
98DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_LIST, ATTR_MALLOC, \
99 ATTR_NULL, ATTR_NOTHROW_LIST)
79ed7328 100
00362064 101DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_1, ATTR_NONNULL, ATTR_LIST_1, \
08291658 102 ATTR_NOTHROW_LIST)
00362064 103DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_2, ATTR_NONNULL, ATTR_LIST_2, \
08291658 104 ATTR_NOTHROW_LIST)
00362064 105DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_3, ATTR_NONNULL, ATTR_LIST_3, \
08291658 106 ATTR_NOTHROW_LIST)
2b72593e 107/* Nothrow functions whose first and second parameters are nonnull pointers. */
00362064
KG
108DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_1_2, ATTR_NONNULL, ATTR_LIST_2, \
109 ATTR_NOTHROW_NONNULL_1)
2b72593e 110/* Nothrow functions whose first and fourth parameters are nonnull pointers. */
00362064
KG
111DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_1_4, ATTR_NONNULL, ATTR_LIST_4, \
112 ATTR_NOTHROW_NONNULL_1)
2b72593e 113/* Nothrow const functions whose first parameter is a nonnull pointer. */
00362064
KG
114DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_NONNULL_1, ATTR_CONST, ATTR_NULL, \
115 ATTR_NOTHROW_NONNULL_1)
2b72593e 116/* Nothrow pure functions whose first parameter is a nonnull pointer. */
00362064
KG
117DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_NONNULL_1, ATTR_PURE, ATTR_NULL, \
118 ATTR_NOTHROW_NONNULL_1)
2b72593e 119/* Nothrow pure functions whose first and second parameters are nonnull pointers. */
00362064
KG
120DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_NONNULL_1_2, ATTR_PURE, ATTR_NULL, \
121 ATTR_NOTHROW_NONNULL_1_2)
2b72593e 122/* Nothrow malloc functions whose first parameter is a nonnull pointer. */
00362064
KG
123DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_NONNULL_1, ATTR_MALLOC, ATTR_NULL, \
124 ATTR_NOTHROW_NONNULL_1)
79ed7328 125
6431177a 126/* Construct a tree for a format attribute. */
79ed7328 127#define DEF_FORMAT_ATTRIBUTE(TYPE, FA, VALUES) \
9a238586
KG
128 DEF_ATTR_TREE_LIST (ATTR_##TYPE##_##VALUES, ATTR_NULL, \
129 ATTR_##TYPE, ATTR_LIST_##VALUES) \
130 DEF_ATTR_TREE_LIST (ATTR_FORMAT_##TYPE##_##VALUES, ATTR_FORMAT, \
131 ATTR_##TYPE##_##VALUES, ATTR_NOTHROW_NONNULL_##FA)
79ed7328
JT
132DEF_FORMAT_ATTRIBUTE(PRINTF,1,1_0)
133DEF_FORMAT_ATTRIBUTE(PRINTF,1,1_2)
134DEF_FORMAT_ATTRIBUTE(PRINTF,2,2_0)
135DEF_FORMAT_ATTRIBUTE(PRINTF,2,2_3)
136DEF_FORMAT_ATTRIBUTE(PRINTF,3,3_0)
137DEF_FORMAT_ATTRIBUTE(PRINTF,3,3_4)
138DEF_FORMAT_ATTRIBUTE(SCANF,1,1_0)
139DEF_FORMAT_ATTRIBUTE(SCANF,1,1_2)
140DEF_FORMAT_ATTRIBUTE(SCANF,2,2_0)
141DEF_FORMAT_ATTRIBUTE(SCANF,2,2_3)
142DEF_FORMAT_ATTRIBUTE(STRFTIME,3,3_0)
143DEF_FORMAT_ATTRIBUTE(STRFMON,3,3_4)
6431177a
JM
144#undef DEF_FORMAT_ATTRIBUTE
145
79ed7328
JT
146/* Construct a tree for a format_arg attribute. */
147#define DEF_FORMAT_ARG_ATTRIBUTE(FA) \
9a238586
KG
148 DEF_ATTR_TREE_LIST (ATTR_FORMAT_ARG_##FA, ATTR_FORMAT_ARG, \
149 ATTR_LIST_##FA, ATTR_NOTHROW_NONNULL_##FA)
79ed7328
JT
150DEF_FORMAT_ARG_ATTRIBUTE(1)
151DEF_FORMAT_ARG_ATTRIBUTE(2)
152#undef DEF_FORMAT_ARG_ATTRIBUTE
6431177a 153