comparison gcc/c-family/c-format.h @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents 561a7518be6b
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* Check calls to formatted I/O functions (-Wformat). 1 /* Check calls to formatted I/O functions (-Wformat).
2 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2 Copyright (C) 1992-2017 Free Software Foundation, Inc.
3 2001, 2002, 2003, 2004, 2007, 2008, 2010 Free Software Foundation, Inc.
4 3
5 This file is part of GCC. 4 This file is part of GCC.
6 5
7 GCC is free software; you can redistribute it and/or modify it under 6 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 7 the terms of the GNU General Public License as published by the Free
83 of whether length modifiers can occur (length_char_specs). */ 82 of whether length modifiers can occur (length_char_specs). */
84 }; 83 };
85 84
86 /* Structure describing a length modifier supported in format checking, and 85 /* Structure describing a length modifier supported in format checking, and
87 possibly a doubled version such as "hh". */ 86 possibly a doubled version such as "hh". */
88 typedef struct 87 struct format_length_info
89 { 88 {
90 /* Name of the single-character length modifier. If prefixed by 89 /* Name of the single-character length modifier. If prefixed by
91 a zero character, it describes a multi character length 90 a zero character, it describes a multi character length
92 modifier, like I64, I32, etc. */ 91 modifier, like I64, I32, etc. */
93 const char *name; 92 const char *name;
101 enum format_std_version double_std; 100 enum format_std_version double_std;
102 101
103 /* If this flag is set, just scalar width identity is checked, and 102 /* If this flag is set, just scalar width identity is checked, and
104 not the type identity itself. */ 103 not the type identity itself. */
105 int scalar_identity_flag; 104 int scalar_identity_flag;
106 } format_length_info; 105 };
107 106
108 107
109 /* Structure describing the combination of a conversion specifier 108 /* Structure describing the combination of a conversion specifier
110 (or a set of specifiers which act identically) and a length modifier. */ 109 (or a set of specifiers which act identically) and a length modifier. */
111 typedef struct 110 struct format_type_detail
112 { 111 {
113 /* The standard version this combination of length and type appeared in. 112 /* The standard version this combination of length and type appeared in.
114 This is only relevant if greater than those for length and type 113 This is only relevant if greater than those for length and type
115 individually; otherwise it is ignored. */ 114 individually; otherwise it is ignored. */
116 enum format_std_version std; 115 enum format_std_version std;
117 /* The name to use for the type, if different from that generated internally 116 /* The name to use for the type, if different from that generated internally
118 (e.g., "signed size_t"). */ 117 (e.g., "signed size_t"). */
119 const char *name; 118 const char *name;
120 /* The type itself. */ 119 /* The type itself. */
121 tree *type; 120 tree *type;
122 } format_type_detail; 121 };
123 122
124 123
125 /* Macros to fill out tables of these. */ 124 /* Macros to fill out tables of these. */
126 #define NOARGUMENTS { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN } 125 #define NOARGUMENTS { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }
127 #define BADLEN { STD_C89, NULL, NULL } 126 #define BADLEN { STD_C89, NULL, NULL }
128 #define NOLENGTHS { BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN } 127 #define NOLENGTHS { BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }
129 128
130 129
131 /* Structure describing a format conversion specifier (or a set of specifiers 130 /* Structure describing a format conversion specifier (or a set of specifiers
132 which act identically), and the length modifiers used with it. */ 131 which act identically), and the length modifiers used with it. */
133 typedef struct format_char_info 132 struct format_char_info
134 { 133 {
135 const char *format_chars; 134 const char *format_chars;
136 int pointer_count; 135 int pointer_count;
137 enum format_std_version std; 136 enum format_std_version std;
138 /* Types accepted for each length modifier. */ 137 /* Types accepted for each length modifier. */
150 years in some locales, "4" for "2" which becomes "3" with an "E" modifier, 149 years in some locales, "4" for "2" which becomes "3" with an "E" modifier,
151 "o" if use of strftime "O" is a GNU extension beyond C99, 150 "o" if use of strftime "O" is a GNU extension beyond C99,
152 "W" if the argument is a pointer which is dereferenced and written into, 151 "W" if the argument is a pointer which is dereferenced and written into,
153 "R" if the argument is a pointer which is dereferenced and read from, 152 "R" if the argument is a pointer which is dereferenced and read from,
154 "i" for printf integer formats where the '0' flag is ignored with 153 "i" for printf integer formats where the '0' flag is ignored with
155 precision, and "[" for the starting character of a scanf scanset. */ 154 precision, and "[" for the starting character of a scanf scanset,
155 "<" if the specifier introduces a quoted sequence (such as "%<"),
156 ">" if the specifier terminates a quoted sequence (such as "%>"),
157 "[" if the specifier introduces a color sequence (such as "%r"),
158 "]" if the specifier terminates a color sequence (such as "%R"),
159 "'" (single quote) if the specifier is expected to be quoted when
160 it appears outside a quoted sequence and unquoted otherwise (such
161 as the GCC internal printf format directive "%T"), and
162 "\"" (double quote) if the specifier is not expected to appear in
163 a quoted sequence (such as the GCC internal format directive "%K". */
156 const char *flags2; 164 const char *flags2;
157 /* If this format conversion character consumes more than one argument, 165 /* If this format conversion character consumes more than one argument,
158 CHAIN points to information about the next argument. For later 166 CHAIN points to information about the next argument. For later
159 arguments, only POINTER_COUNT, TYPES, and the "c", "R", and "W" flags 167 arguments, only POINTER_COUNT, TYPES, and the "c", "R", and "W" flags
160 in FLAGS2 are used. */ 168 in FLAGS2 are used. */
161 const struct format_char_info *chain; 169 const struct format_char_info *chain;
162 } format_char_info; 170 };
163 171
164 172
165 /* Structure describing a flag accepted by some kind of format. */ 173 /* Structure describing a flag accepted by some kind of format. */
166 typedef struct 174 struct format_flag_spec
167 { 175 {
168 /* The flag character in question (0 for end of array). */ 176 /* The flag character in question (0 for end of array). */
169 int flag_char; 177 int flag_char;
170 /* Zero if this entry describes the flag character in general, or a 178 /* Zero if this entry describes the flag character in general, or a
171 nonzero character that may be found in flags2 if it describes the 179 nonzero character that may be found in flags2 if it describes the
177 for strftime formats (meaning 'O' is an extension over C99). */ 185 for strftime formats (meaning 'O' is an extension over C99). */
178 int predicate; 186 int predicate;
179 /* Nonzero if the next character after this flag in the format should 187 /* Nonzero if the next character after this flag in the format should
180 be skipped ('=' in strfmon), zero otherwise. */ 188 be skipped ('=' in strfmon), zero otherwise. */
181 int skip_next_char; 189 int skip_next_char;
190 /* True if the flag introduces quoting (as in GCC's %qE). */
191 bool quoting;
182 /* The name to use for this flag in diagnostic messages. For example, 192 /* The name to use for this flag in diagnostic messages. For example,
183 N_("'0' flag"), N_("field width"). */ 193 N_("'0' flag"), N_("field width"). */
184 const char *name; 194 const char *name;
185 /* Long name for this flag in diagnostic messages; currently only used for 195 /* Long name for this flag in diagnostic messages; currently only used for
186 "ISO C does not support ...". For example, N_("the 'I' printf flag"). */ 196 "ISO C does not support ...". For example, N_("the 'I' printf flag"). */
187 const char *long_name; 197 const char *long_name;
188 /* The standard version in which it appeared. */ 198 /* The standard version in which it appeared. */
189 enum format_std_version std; 199 enum format_std_version std;
190 } format_flag_spec; 200 };
191 201
192 202
193 /* Structure describing a combination of flags that is bad for some kind 203 /* Structure describing a combination of flags that is bad for some kind
194 of format. */ 204 of format. */
195 typedef struct 205 struct format_flag_pair
196 { 206 {
197 /* The first flag character in question (0 for end of array). */ 207 /* The first flag character in question (0 for end of array). */
198 int flag_char1; 208 int flag_char1;
199 /* The second flag character. */ 209 /* The second flag character. */
200 int flag_char2; 210 int flag_char2;
203 int ignored; 213 int ignored;
204 /* Zero if this entry applies whenever this flag combination occurs, 214 /* Zero if this entry applies whenever this flag combination occurs,
205 a nonzero character from flags2 if it only applies in some 215 a nonzero character from flags2 if it only applies in some
206 circumstances (e.g. 'i' for printf formats ignoring 0 with precision). */ 216 circumstances (e.g. 'i' for printf formats ignoring 0 with precision). */
207 int predicate; 217 int predicate;
208 } format_flag_pair; 218 };
209 219
210 220
211 /* Structure describing a particular kind of format processed by GCC. */ 221 /* Structure describing a particular kind of format processed by GCC. */
212 typedef struct 222 struct format_kind_info
213 { 223 {
214 /* The name of this kind of format, for use in diagnostics. Also 224 /* The name of this kind of format, for use in diagnostics. Also
215 the name of the attribute (without preceding and following __). */ 225 the name of the attribute (without preceding and following __). */
216 const char *name; 226 const char *name;
217 /* Specifications of the length modifiers accepted; possibly NULL. */ 227 /* Specifications of the length modifiers accepted; possibly NULL. */
250 or NULL if '*' not used for widths. */ 260 or NULL if '*' not used for widths. */
251 tree *width_type; 261 tree *width_type;
252 /* Pointer to type of argument expected if '*' is used for a precision, 262 /* Pointer to type of argument expected if '*' is used for a precision,
253 or NULL if '*' not used for precisions. */ 263 or NULL if '*' not used for precisions. */
254 tree *precision_type; 264 tree *precision_type;
255 } format_kind_info; 265 };
256 266
257 #define T_I &integer_type_node 267 #define T_I &integer_type_node
258 #define T89_I { STD_C89, NULL, T_I } 268 #define T89_I { STD_C89, NULL, T_I }
259 #define T_L &long_integer_type_node 269 #define T_L &long_integer_type_node
260 #define T89_L { STD_C89, NULL, T_L } 270 #define T89_L { STD_C89, NULL, T_L }
286 #define T_SC &signed_char_type_node 296 #define T_SC &signed_char_type_node
287 #define T99_SC { STD_C99, NULL, T_SC } 297 #define T99_SC { STD_C99, NULL, T_SC }
288 #define T_UC &unsigned_char_type_node 298 #define T_UC &unsigned_char_type_node
289 #define T99_UC { STD_C99, NULL, T_UC } 299 #define T99_UC { STD_C99, NULL, T_UC }
290 #define T_V &void_type_node 300 #define T_V &void_type_node
301 #define T89_G { STD_C89, NULL, &local_gcall_ptr_node }
302 #define T89_T { STD_C89, NULL, &local_tree_type_node }
291 #define T89_V { STD_C89, NULL, T_V } 303 #define T89_V { STD_C89, NULL, T_V }
292 #define T_W &wchar_type_node 304 #define T_W &wchar_type_node
293 #define T94_W { STD_C94, "wchar_t", T_W } 305 #define T94_W { STD_C94, "wchar_t", T_W }
294 #define TEX_W { STD_EXT, "wchar_t", T_W } 306 #define TEX_W { STD_EXT, "wchar_t", T_W }
295 #define T_WI &wint_type_node 307 #define T_WI &wint_type_node
316 328
317 /* Structure describing how format attributes such as "printf" are 329 /* Structure describing how format attributes such as "printf" are
318 interpreted as "gnu_printf" or "ms_printf" on a particular system. 330 interpreted as "gnu_printf" or "ms_printf" on a particular system.
319 TARGET_OVERRIDES_FORMAT_ATTRIBUTES is used to specify target-specific 331 TARGET_OVERRIDES_FORMAT_ATTRIBUTES is used to specify target-specific
320 defaults. */ 332 defaults. */
321 typedef struct 333 struct target_ovr_attr
322 { 334 {
323 /* The name of the to be copied format attribute. */ 335 /* The name of the to be copied format attribute. */
324 const char *named_attr_src; 336 const char *named_attr_src;
325 /* The name of the to be overridden format attribute. */ 337 /* The name of the to be overridden format attribute. */
326 const char *named_attr_dst; 338 const char *named_attr_dst;
327 } target_ovr_attr; 339 };
328 340
329 #endif /* GCC_C_FORMAT_H */ 341 #endif /* GCC_C_FORMAT_H */