Mercurial > hg > CbC > CbC_gcc
annotate gcc/config/i386/msformat-c.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | f6334be47118 |
children | 84e7813d76e9 |
rev | line source |
---|---|
0 | 1 /* Check calls to formatted I/O functions (-Wformat). |
111 | 2 Copyright (C) 1992-2017 Free Software Foundation, Inc. |
0 | 3 |
4 This file is part of GCC. | |
5 | |
6 GCC is free software; you can redistribute it and/or modify it under | |
7 the terms of the GNU General Public License as published by the Free | |
8 Software Foundation; either version 3, or (at your option) any later | |
9 version. | |
10 | |
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GCC; see the file COPYING3. If not see | |
18 <http://www.gnu.org/licenses/>. */ | |
19 | |
20 #include "config.h" | |
21 #include "system.h" | |
22 #include "coretypes.h" | |
23 #include "tm.h" | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
24 #include "c-family/c-common.h" |
0 | 25 #include "intl.h" |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
26 #include "c-family/c-format.h" |
0 | 27 |
28 /* Mingw specific format attributes ms_printf, ms_scanf, and ms_strftime. */ | |
29 | |
30 static format_length_info ms_printf_length_specs[] = | |
31 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
32 { "h", FMT_LEN_h, STD_C89, NULL, FMT_LEN_none, STD_C89, 0 }, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
33 { "l", FMT_LEN_l, STD_C89, NULL, FMT_LEN_none, STD_C89, 0 }, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
34 { "I32", FMT_LEN_l, STD_EXT, NULL, FMT_LEN_none, STD_C89, 1 }, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
35 { "I64", FMT_LEN_ll, STD_EXT, NULL, FMT_LEN_none, STD_C89, 1 }, |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
36 { "I", FMT_LEN_L, STD_EXT, NULL, FMT_LEN_none, STD_C89, 1 }, |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
37 { NULL, FMT_LEN_none, STD_C89, NULL, FMT_LEN_none, STD_C89, 0 } |
0 | 38 }; |
39 | |
40 static const format_flag_spec ms_printf_flag_specs[] = | |
41 { | |
111 | 42 { ' ', 0, 0, 0, N_("' ' flag"), N_("the ' ' printf flag"), STD_C89 }, |
43 { '+', 0, 0, 0, N_("'+' flag"), N_("the '+' printf flag"), STD_C89 }, | |
44 { '#', 0, 0, 0, N_("'#' flag"), N_("the '#' printf flag"), STD_C89 }, | |
45 { '0', 0, 0, 0, N_("'0' flag"), N_("the '0' printf flag"), STD_C89 }, | |
46 { '-', 0, 0, 0, N_("'-' flag"), N_("the '-' printf flag"), STD_C89 }, | |
47 { '\'', 0, 0, 0, N_("''' flag"), N_("the ''' printf flag"), STD_EXT }, | |
48 { 'w', 0, 0, 0, N_("field width"), N_("field width in printf format"), STD_C89 }, | |
49 { 'p', 0, 0, 0, N_("precision"), N_("precision in printf format"), STD_C89 }, | |
50 { 'L', 0, 0, 0, N_("length modifier"), N_("length modifier in printf format"), STD_C89 }, | |
51 { 0, 0, 0, 0, NULL, NULL, STD_C89 } | |
0 | 52 }; |
53 | |
54 static const format_flag_pair ms_printf_flag_pairs[] = | |
55 { | |
56 { ' ', '+', 1, 0 }, | |
57 { '0', '-', 1, 0 }, { '0', 'p', 1, 'i' }, | |
58 { 0, 0, 0, 0 } | |
59 }; | |
60 | |
61 static const format_flag_spec ms_scanf_flag_specs[] = | |
62 { | |
111 | 63 { '*', 0, 0, 0, N_("assignment suppression"), N_("the assignment suppression scanf feature"), STD_C89 }, |
64 { 'a', 0, 0, 0, N_("'a' flag"), N_("the 'a' scanf flag"), STD_EXT }, | |
65 { 'w', 0, 0, 0, N_("field width"), N_("field width in scanf format"), STD_C89 }, | |
66 { 'L', 0, 0, 0, N_("length modifier"), N_("length modifier in scanf format"), STD_C89 }, | |
67 { '\'', 0, 0, 0, N_("''' flag"), N_("the ''' scanf flag"), STD_EXT }, | |
68 { 0, 0, 0, 0, NULL, NULL, STD_C89 } | |
0 | 69 }; |
70 | |
71 static const format_flag_pair ms_scanf_flag_pairs[] = | |
72 { | |
73 { '*', 'L', 0, 0 }, | |
74 { 0, 0, 0, 0 } | |
75 }; | |
76 | |
77 static const format_flag_spec ms_strftime_flag_specs[] = | |
78 { | |
111 | 79 { '#', 0, 0, 0, N_("'#' flag"), N_("the '#' strftime flag"), STD_EXT }, |
80 { 0, 0, 0, 0, NULL, NULL, STD_C89 } | |
0 | 81 }; |
82 | |
83 static const format_flag_pair ms_strftime_flag_pairs[] = | |
84 { | |
85 { 0, 0, 0, 0 } | |
86 }; | |
87 | |
88 static const format_char_info ms_print_char_table[] = | |
89 { | |
90 /* C89 conversion specifiers. */ | |
91 { "di", 0, STD_C89, { T89_I, BADLEN, T89_S, T89_L, T9L_LL, T99_SST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +'", "i", NULL }, | |
92 { "oxX", 0, STD_C89, { T89_UI, BADLEN, T89_US, T89_UL, T9L_ULL, T99_ST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0#", "i", NULL }, | |
93 { "u", 0, STD_C89, { T89_UI, BADLEN, T89_US, T89_UL, T9L_ULL, T99_ST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0'", "i", NULL }, | |
94 { "fgG", 0, STD_C89, { T89_D, BADLEN, BADLEN, T99_D, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +#'", "", NULL }, | |
95 { "eE", 0, STD_C89, { T89_D, BADLEN, BADLEN, T99_D, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +#", "", NULL }, | |
96 { "c", 0, STD_C89, { T89_I, BADLEN, T89_S, T94_WI, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "", NULL }, | |
97 { "s", 1, STD_C89, { T89_C, BADLEN, T89_S, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "cR", NULL }, | |
98 { "p", 1, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "c", NULL }, | |
99 { "n", 1, STD_C89, { T89_I, BADLEN, T89_S, T89_L, T9L_LL, BADLEN, BADLEN, BADLEN, T99_IM, BADLEN, BADLEN, BADLEN }, "", "W", NULL }, | |
100 /* X/Open conversion specifiers. */ | |
101 { "C", 0, STD_EXT, { TEX_WI, BADLEN, T89_S, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "", NULL }, | |
102 { "S", 1, STD_EXT, { TEX_W, BADLEN, T89_S, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "R", NULL }, | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
103 { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL } |
0 | 104 }; |
105 | |
106 static const format_char_info ms_scan_char_table[] = | |
107 { | |
108 /* C89 conversion specifiers. */ | |
109 { "di", 1, STD_C89, { T89_I, BADLEN, T89_S, T89_L, T9L_LL, T99_SST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w'", "W", NULL }, | |
110 { "u", 1, STD_C89, { T89_UI, BADLEN, T89_US, T89_UL, T9L_ULL, T99_ST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w'", "W", NULL }, | |
111 { "oxX", 1, STD_C89, { T89_UI, BADLEN, T89_US, T89_UL, T9L_ULL, T99_ST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w", "W", NULL }, | |
112 { "efgEG", 1, STD_C89, { T89_F, BADLEN, BADLEN, T89_D, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w'", "W", NULL }, | |
113 { "c", 1, STD_C89, { T89_C, BADLEN, T89_S, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w", "cW", NULL }, | |
114 { "s", 1, STD_C89, { T89_C, BADLEN, T89_S, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*aw", "cW", NULL }, | |
115 { "[", 1, STD_C89, { T89_C, BADLEN, BADLEN, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*aw", "cW[", NULL }, | |
116 { "p", 2, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w", "W", NULL }, | |
117 { "n", 1, STD_C89, { T89_I, BADLEN, T89_S, T89_L, T9L_LL, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "W", NULL }, | |
118 /* X/Open conversion specifiers. */ | |
119 { "C", 1, STD_EXT, { TEX_W, BADLEN, T89_S, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w", "W", NULL }, | |
120 { "S", 1, STD_EXT, { TEX_W, BADLEN, T89_S, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*aw", "W", NULL }, | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
121 { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL } |
0 | 122 }; |
123 | |
124 static const format_char_info ms_time_char_table[] = | |
125 { | |
126 /* C89 conversion specifiers. */ | |
127 { "ABZab", 0, STD_C89, NOLENGTHS, "#", "", NULL }, | |
128 { "cx", 0, STD_C89, NOLENGTHS, "#", "3", NULL }, | |
129 { "HIMSUWdmw", 0, STD_C89, NOLENGTHS, "#", "", NULL }, | |
130 { "j", 0, STD_C89, NOLENGTHS, "#", "", NULL }, | |
131 { "p", 0, STD_C89, NOLENGTHS, "#", "", NULL }, | |
132 { "X", 0, STD_C89, NOLENGTHS, "#", "", NULL }, | |
133 { "y", 0, STD_C89, NOLENGTHS, "#", "4", NULL }, | |
134 { "Y", 0, STD_C89, NOLENGTHS, "#", "", NULL }, | |
135 { "%", 0, STD_C89, NOLENGTHS, "", "", NULL }, | |
136 /* C99 conversion specifiers. */ | |
137 { "z", 0, STD_C99, NOLENGTHS, "#", "", NULL }, | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
138 { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL } |
0 | 139 }; |
140 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
141 EXPORTED_CONST format_kind_info mingw_format_attributes[3] = |
0 | 142 { |
143 { "ms_printf", ms_printf_length_specs, ms_print_char_table, " +#0-'", NULL, | |
144 ms_printf_flag_specs, ms_printf_flag_pairs, | |
145 FMT_FLAG_ARG_CONVERT|FMT_FLAG_DOLLAR_MULTIPLE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_EMPTY_PREC_OK, | |
146 'w', 0, 'p', 0, 'L', 0, | |
147 &integer_type_node, &integer_type_node | |
148 }, | |
149 { "ms_scanf", ms_printf_length_specs, ms_scan_char_table, "*'", NULL, | |
150 ms_scanf_flag_specs, ms_scanf_flag_pairs, | |
151 FMT_FLAG_ARG_CONVERT|FMT_FLAG_SCANF_A_KLUDGE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_ZERO_WIDTH_BAD|FMT_FLAG_DOLLAR_GAP_POINTER_OK, | |
152 'w', 0, 0, '*', 'L', 0, | |
153 NULL, NULL | |
154 }, | |
155 { "ms_strftime", NULL, ms_time_char_table, "", "#", | |
156 ms_strftime_flag_specs, ms_strftime_flag_pairs, | |
157 FMT_FLAG_FANCY_PERCENT_OK, 0, 0, 0, 0, 0, 0, | |
158 NULL, NULL | |
159 } | |
160 }; | |
161 | |
162 /* Default overrides for printf, scanf and strftime. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
163 EXPORTED_CONST target_ovr_attr mingw_format_attribute_overrides[4] = |
0 | 164 { |
165 { "ms_printf", "printf" }, | |
166 { "ms_scanf", "scanf" }, | |
167 { "ms_strftime", "strftime" } | |
168 }; | |
169 | |
170 /* Setup for option Wpedantic-ms-format. */ | |
171 | |
172 #ifdef TARGET_OVERRIDES_FORMAT_INIT | |
173 | |
174 /* Make sure TARGET_OVERRIDES_FORMAT_INIT is prototyped. */ | |
175 extern void TARGET_OVERRIDES_FORMAT_INIT (void); | |
176 | |
177 /* Helper. */ | |
178 #define C89_OR_EXT (warn_pedantic_ms_format ? STD_EXT : STD_C89) | |
179 | |
180 void | |
181 TARGET_OVERRIDES_FORMAT_INIT (void) | |
182 { | |
183 ms_printf_length_specs[2].std = C89_OR_EXT; /* I32 */ | |
184 ms_printf_length_specs[3].std = C89_OR_EXT; /* I64 */ | |
185 ms_printf_length_specs[4].std = C89_OR_EXT; /* I */ | |
186 } | |
187 | |
188 #undef C89_OR_EXT | |
189 | |
190 #endif |