]> gcc.gnu.org Git - gcc.git/blame - gcc/builtin-attrs.def
* cfgloop.c (flow_loops_cfg_dump): Use bb->index, not i.
[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
44 as previous ENUM names).
45
46 DEF_FN_ATTR (NAME, ATTRS, PREDICATE)
47
48 Specifies that the function with name NAME (a previous ENUM for an
49 IDENTIFIER_NODE) has attributes ATTRS (a previous ENUM) if
50 PREDICATE is true. */
51
52DEF_ATTR_NULL_TREE (ATTR_NULL)
53
54/* Note that below we must avoid whitespace in arguments of CONCAT*. */
55
56/* Construct a tree for a given integer and a list containing it. */
57#define DEF_ATTR_FOR_INT(VALUE) \
58 DEF_ATTR_INT (CONCAT2 (ATTR_,VALUE), VALUE) \
59 DEF_ATTR_TREE_LIST (CONCAT2 (ATTR_LIST_,VALUE), ATTR_NULL, \
60 CONCAT2 (ATTR_,VALUE), ATTR_NULL)
61DEF_ATTR_FOR_INT (0)
62DEF_ATTR_FOR_INT (1)
63DEF_ATTR_FOR_INT (2)
64DEF_ATTR_FOR_INT (3)
65DEF_ATTR_FOR_INT (4)
66#undef DEF_ATTR_FOR_INT
67
68/* Construct a tree for a list of two integers. */
69#define DEF_LIST_INT_INT(VALUE1, VALUE2) \
70 DEF_ATTR_TREE_LIST (CONCAT4 (ATTR_LIST_,VALUE1,_,VALUE2), ATTR_NULL, \
71 CONCAT2 (ATTR_,VALUE1), CONCAT2 (ATTR_LIST_,VALUE2))
72DEF_LIST_INT_INT (1,0)
73DEF_LIST_INT_INT (1,2)
74DEF_LIST_INT_INT (2,0)
75DEF_LIST_INT_INT (2,3)
76DEF_LIST_INT_INT (3,0)
77DEF_LIST_INT_INT (3,4)
78#undef DEF_LIST_INT_INT
79
80DEF_ATTR_IDENT (ATTR_PRINTF, "printf")
81DEF_ATTR_IDENT (ATTR_SCANF, "scanf")
82DEF_ATTR_IDENT (ATTR_STRFTIME, "strftime")
83DEF_ATTR_IDENT (ATTR_STRFMON, "strfmon")
84
85DEF_ATTR_IDENT (ATTR_FORMAT, "format")
86DEF_ATTR_IDENT (ATTR_FORMAT_ARG, "format_arg")
87
79ed7328
JT
88DEF_ATTR_IDENT (ATTR_NONNULL, "nonnull")
89
90DEF_ATTR_TREE_LIST (ATTR_NONNULL_1, ATTR_NONNULL, ATTR_LIST_1, ATTR_NULL)
91DEF_ATTR_TREE_LIST (ATTR_NONNULL_2, ATTR_NONNULL, ATTR_LIST_2, ATTR_NULL)
92DEF_ATTR_TREE_LIST (ATTR_NONNULL_3, ATTR_NONNULL, ATTR_LIST_3, ATTR_NULL)
93
6431177a 94/* Construct a tree for a format attribute. */
79ed7328 95#define DEF_FORMAT_ATTRIBUTE(TYPE, FA, VALUES) \
6431177a
JM
96 DEF_ATTR_TREE_LIST (CONCAT4 (ATTR_,TYPE,_,VALUES), ATTR_NULL, \
97 CONCAT2 (ATTR_,TYPE), CONCAT2 (ATTR_LIST_,VALUES)) \
98 DEF_ATTR_TREE_LIST (CONCAT4 (ATTR_FORMAT_,TYPE,_,VALUES), ATTR_FORMAT, \
79ed7328
JT
99 CONCAT4 (ATTR_,TYPE,_,VALUES), CONCAT2 (ATTR_NONNULL_,FA))
100DEF_FORMAT_ATTRIBUTE(PRINTF,1,1_0)
101DEF_FORMAT_ATTRIBUTE(PRINTF,1,1_2)
102DEF_FORMAT_ATTRIBUTE(PRINTF,2,2_0)
103DEF_FORMAT_ATTRIBUTE(PRINTF,2,2_3)
104DEF_FORMAT_ATTRIBUTE(PRINTF,3,3_0)
105DEF_FORMAT_ATTRIBUTE(PRINTF,3,3_4)
106DEF_FORMAT_ATTRIBUTE(SCANF,1,1_0)
107DEF_FORMAT_ATTRIBUTE(SCANF,1,1_2)
108DEF_FORMAT_ATTRIBUTE(SCANF,2,2_0)
109DEF_FORMAT_ATTRIBUTE(SCANF,2,2_3)
110DEF_FORMAT_ATTRIBUTE(STRFTIME,3,3_0)
111DEF_FORMAT_ATTRIBUTE(STRFMON,3,3_4)
6431177a
JM
112#undef DEF_FORMAT_ATTRIBUTE
113
79ed7328
JT
114/* Construct a tree for a format_arg attribute. */
115#define DEF_FORMAT_ARG_ATTRIBUTE(FA) \
116 DEF_ATTR_TREE_LIST (CONCAT2 (ATTR_FORMAT_ARG_,FA), ATTR_FORMAT_ARG, \
117 CONCAT2 (ATTR_LIST_,FA), CONCAT2 (ATTR_NONNULL_,FA))
118DEF_FORMAT_ARG_ATTRIBUTE(1)
119DEF_FORMAT_ARG_ATTRIBUTE(2)
120#undef DEF_FORMAT_ARG_ATTRIBUTE
6431177a
JM
121
122/* Define an attribute for a function, along with the IDENTIFIER_NODE. */
123#define DEF_FN_ATTR_IDENT(NAME, ATTRS, PREDICATE) \
124 DEF_ATTR_IDENT (CONCAT2(ATTR_,NAME), STRINGX(NAME)) \
125 DEF_FN_ATTR (CONCAT2(ATTR_,NAME), ATTRS, PREDICATE)
126
127/* The ISO C functions are always checked (whether <stdio.h> is
128 included or not), since it is common to call printf without
129 including <stdio.h>. There shouldn't be a problem with this,
130 since ISO C reserves these function names whether you include the
131 header file or not. In any case, the checking is harmless. With
132 -ffreestanding, these default attributes are disabled, and must be
133 specified manually if desired. */
134
135/* __builtin functions should be checked unconditionally, even with
136 -ffreestanding. */
137DEF_FN_ATTR_IDENT (__builtin_printf, ATTR_FORMAT_PRINTF_1_2, true)
138DEF_FN_ATTR_IDENT (__builtin_fprintf, ATTR_FORMAT_PRINTF_2_3, true)
b4c984fb
KG
139DEF_FN_ATTR_IDENT (__builtin_printf_unlocked, ATTR_FORMAT_PRINTF_1_2, true)
140DEF_FN_ATTR_IDENT (__builtin_fprintf_unlocked, ATTR_FORMAT_PRINTF_2_3, true)
6431177a
JM
141
142/* Functions from ISO/IEC 9899:1990. */
143#define DEF_C89_ATTR(NAME, ATTRS) DEF_FN_ATTR_IDENT (NAME, ATTRS, flag_hosted)
144DEF_C89_ATTR (printf, ATTR_FORMAT_PRINTF_1_2)
145DEF_C89_ATTR (fprintf, ATTR_FORMAT_PRINTF_2_3)
146DEF_C89_ATTR (sprintf, ATTR_FORMAT_PRINTF_2_3)
147DEF_C89_ATTR (scanf, ATTR_FORMAT_SCANF_1_2)
148DEF_C89_ATTR (fscanf, ATTR_FORMAT_SCANF_2_3)
149DEF_C89_ATTR (sscanf, ATTR_FORMAT_SCANF_2_3)
150DEF_C89_ATTR (vprintf, ATTR_FORMAT_PRINTF_1_0)
151DEF_C89_ATTR (vfprintf, ATTR_FORMAT_PRINTF_2_0)
152DEF_C89_ATTR (vsprintf, ATTR_FORMAT_PRINTF_2_0)
153DEF_C89_ATTR (strftime, ATTR_FORMAT_STRFTIME_3_0)
154#undef DEF_C89_ATTR
155
156/* ISO C99 adds the snprintf and vscanf family functions. */
157#define DEF_C99_ATTR(NAME, ATTRS) \
158 DEF_FN_ATTR_IDENT (NAME, ATTRS, \
159 (flag_hosted \
160 && (flag_isoc99 || flag_noniso_default_format_attributes)))
161DEF_C99_ATTR (snprintf, ATTR_FORMAT_PRINTF_3_4)
162DEF_C99_ATTR (vsnprintf, ATTR_FORMAT_PRINTF_3_0)
163DEF_C99_ATTR (vscanf, ATTR_FORMAT_SCANF_1_0)
164DEF_C99_ATTR (vfscanf, ATTR_FORMAT_SCANF_2_0)
165DEF_C99_ATTR (vsscanf, ATTR_FORMAT_SCANF_2_0)
166#undef DEF_C99_ATTR
167
168/* Functions not in any version of ISO C. */
169#define DEF_EXT_ATTR(NAME, ATTRS) \
170 DEF_FN_ATTR_IDENT (NAME, ATTRS, \
171 flag_hosted && flag_noniso_default_format_attributes)
172/* Uniforum/GNU gettext functions. */
173DEF_EXT_ATTR (gettext, ATTR_FORMAT_ARG_1)
174DEF_EXT_ATTR (dgettext, ATTR_FORMAT_ARG_2)
175DEF_EXT_ATTR (dcgettext, ATTR_FORMAT_ARG_2)
176/* X/Open strfmon function. */
177DEF_EXT_ATTR (strfmon, ATTR_FORMAT_STRFMON_3_4)
b4c984fb
KG
178/* Glibc thread-unsafe stdio functions. */
179DEF_EXT_ATTR (printf_unlocked, ATTR_FORMAT_PRINTF_1_2)
180DEF_EXT_ATTR (fprintf_unlocked, ATTR_FORMAT_PRINTF_2_3)
6431177a
JM
181#undef DEF_EXT_ATTR
182#undef DEF_FN_ATTR_IDENT
This page took 0.160709 seconds and 5 git commands to generate.