Mercurial > hg > CbC > CbC_gcc
annotate gcc/config/i386/msformat-c.c @ 158:494b0b89df80 default tip
...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2020 18:13:55 +0900 |
parents | 1830386684a0 |
children |
rev | line source |
---|---|
0 | 1 /* Check calls to formatted I/O functions (-Wformat). |
145 | 2 Copyright (C) 1992-2020 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 | |
131 | 20 #define IN_TARGET_CODE 1 |
21 | |
0 | 22 #include "config.h" |
23 #include "system.h" | |
24 #include "coretypes.h" | |
25 #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
|
26 #include "c-family/c-common.h" |
0 | 27 #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
|
28 #include "c-family/c-format.h" |
0 | 29 |
30 /* Mingw specific format attributes ms_printf, ms_scanf, and ms_strftime. */ | |
31 | |
32 static format_length_info ms_printf_length_specs[] = | |
33 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
34 { "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
|
35 { "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
|
36 { "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
|
37 { "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
|
38 { "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
|
39 { NULL, FMT_LEN_none, STD_C89, NULL, FMT_LEN_none, STD_C89, 0 } |
0 | 40 }; |
41 | |
42 static const format_flag_spec ms_printf_flag_specs[] = | |
43 { | |
111 | 44 { ' ', 0, 0, 0, N_("' ' flag"), N_("the ' ' printf flag"), STD_C89 }, |
45 { '+', 0, 0, 0, N_("'+' flag"), N_("the '+' printf flag"), STD_C89 }, | |
46 { '#', 0, 0, 0, N_("'#' flag"), N_("the '#' printf flag"), STD_C89 }, | |
47 { '0', 0, 0, 0, N_("'0' flag"), N_("the '0' printf flag"), STD_C89 }, | |
48 { '-', 0, 0, 0, N_("'-' flag"), N_("the '-' printf flag"), STD_C89 }, | |
49 { '\'', 0, 0, 0, N_("''' flag"), N_("the ''' printf flag"), STD_EXT }, | |
50 { 'w', 0, 0, 0, N_("field width"), N_("field width in printf format"), STD_C89 }, | |
51 { 'p', 0, 0, 0, N_("precision"), N_("precision in printf format"), STD_C89 }, | |
52 { 'L', 0, 0, 0, N_("length modifier"), N_("length modifier in printf format"), STD_C89 }, | |
53 { 0, 0, 0, 0, NULL, NULL, STD_C89 } | |
0 | 54 }; |
55 | |
56 static const format_flag_pair ms_printf_flag_pairs[] = | |
57 { | |
58 { ' ', '+', 1, 0 }, | |
59 { '0', '-', 1, 0 }, { '0', 'p', 1, 'i' }, | |
60 { 0, 0, 0, 0 } | |
61 }; | |
62 | |
63 static const format_flag_spec ms_scanf_flag_specs[] = | |
64 { | |
111 | 65 { '*', 0, 0, 0, N_("assignment suppression"), N_("the assignment suppression scanf feature"), STD_C89 }, |
66 { 'a', 0, 0, 0, N_("'a' flag"), N_("the 'a' scanf flag"), STD_EXT }, | |
67 { 'w', 0, 0, 0, N_("field width"), N_("field width in scanf format"), STD_C89 }, | |
68 { 'L', 0, 0, 0, N_("length modifier"), N_("length modifier in scanf format"), STD_C89 }, | |
69 { '\'', 0, 0, 0, N_("''' flag"), N_("the ''' scanf flag"), STD_EXT }, | |
70 { 0, 0, 0, 0, NULL, NULL, STD_C89 } | |
0 | 71 }; |
72 | |
73 static const format_flag_pair ms_scanf_flag_pairs[] = | |
74 { | |
75 { '*', 'L', 0, 0 }, | |
76 { 0, 0, 0, 0 } | |
77 }; | |
78 | |
79 static const format_flag_spec ms_strftime_flag_specs[] = | |
80 { | |
111 | 81 { '#', 0, 0, 0, N_("'#' flag"), N_("the '#' strftime flag"), STD_EXT }, |
82 { 0, 0, 0, 0, NULL, NULL, STD_C89 } | |
0 | 83 }; |
84 | |
85 static const format_flag_pair ms_strftime_flag_pairs[] = | |
86 { | |
87 { 0, 0, 0, 0 } | |
88 }; | |
89 | |
90 static const format_char_info ms_print_char_table[] = | |
91 { | |
92 /* C89 conversion specifiers. */ | |
93 { "di", 0, STD_C89, { T89_I, BADLEN, T89_S, T89_L, T9L_LL, T99_SST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +'", "i", NULL }, | |
94 { "oxX", 0, STD_C89, { T89_UI, BADLEN, T89_US, T89_UL, T9L_ULL, T99_ST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0#", "i", NULL }, | |
95 { "u", 0, STD_C89, { T89_UI, BADLEN, T89_US, T89_UL, T9L_ULL, T99_ST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0'", "i", NULL }, | |
96 { "fgG", 0, STD_C89, { T89_D, BADLEN, BADLEN, T99_D, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +#'", "", NULL }, | |
97 { "eE", 0, STD_C89, { T89_D, BADLEN, BADLEN, T99_D, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +#", "", NULL }, | |
98 { "c", 0, STD_C89, { T89_I, BADLEN, T89_S, T94_WI, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "", NULL }, | |
99 { "s", 1, STD_C89, { T89_C, BADLEN, T89_S, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "cR", NULL }, | |
100 { "p", 1, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "c", NULL }, | |
101 { "n", 1, STD_C89, { T89_I, BADLEN, T89_S, T89_L, T9L_LL, BADLEN, BADLEN, BADLEN, T99_IM, BADLEN, BADLEN, BADLEN }, "", "W", NULL }, | |
102 /* X/Open conversion specifiers. */ | |
103 { "C", 0, STD_EXT, { TEX_WI, BADLEN, T89_S, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "", NULL }, | |
104 { "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
|
105 { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL } |
0 | 106 }; |
107 | |
108 static const format_char_info ms_scan_char_table[] = | |
109 { | |
110 /* C89 conversion specifiers. */ | |
111 { "di", 1, STD_C89, { T89_I, BADLEN, T89_S, T89_L, T9L_LL, T99_SST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w'", "W", NULL }, | |
112 { "u", 1, STD_C89, { T89_UI, BADLEN, T89_US, T89_UL, T9L_ULL, T99_ST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w'", "W", NULL }, | |
113 { "oxX", 1, STD_C89, { T89_UI, BADLEN, T89_US, T89_UL, T9L_ULL, T99_ST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w", "W", NULL }, | |
114 { "efgEG", 1, STD_C89, { T89_F, BADLEN, BADLEN, T89_D, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w'", "W", NULL }, | |
115 { "c", 1, STD_C89, { T89_C, BADLEN, T89_S, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w", "cW", NULL }, | |
116 { "s", 1, STD_C89, { T89_C, BADLEN, T89_S, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*aw", "cW", NULL }, | |
117 { "[", 1, STD_C89, { T89_C, BADLEN, BADLEN, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*aw", "cW[", NULL }, | |
118 { "p", 2, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w", "W", NULL }, | |
119 { "n", 1, STD_C89, { T89_I, BADLEN, T89_S, T89_L, T9L_LL, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "W", NULL }, | |
120 /* X/Open conversion specifiers. */ | |
121 { "C", 1, STD_EXT, { TEX_W, BADLEN, T89_S, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w", "W", NULL }, | |
122 { "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
|
123 { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL } |
0 | 124 }; |
125 | |
126 static const format_char_info ms_time_char_table[] = | |
127 { | |
128 /* C89 conversion specifiers. */ | |
129 { "ABZab", 0, STD_C89, NOLENGTHS, "#", "", NULL }, | |
130 { "cx", 0, STD_C89, NOLENGTHS, "#", "3", NULL }, | |
131 { "HIMSUWdmw", 0, STD_C89, NOLENGTHS, "#", "", NULL }, | |
132 { "j", 0, STD_C89, NOLENGTHS, "#", "", NULL }, | |
133 { "p", 0, STD_C89, NOLENGTHS, "#", "", NULL }, | |
134 { "X", 0, STD_C89, NOLENGTHS, "#", "", NULL }, | |
135 { "y", 0, STD_C89, NOLENGTHS, "#", "4", NULL }, | |
136 { "Y", 0, STD_C89, NOLENGTHS, "#", "", NULL }, | |
137 { "%", 0, STD_C89, NOLENGTHS, "", "", NULL }, | |
138 /* C99 conversion specifiers. */ | |
139 { "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
|
140 { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL } |
0 | 141 }; |
142 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
143 EXPORTED_CONST format_kind_info mingw_format_attributes[3] = |
0 | 144 { |
145 { "ms_printf", ms_printf_length_specs, ms_print_char_table, " +#0-'", NULL, | |
146 ms_printf_flag_specs, ms_printf_flag_pairs, | |
147 FMT_FLAG_ARG_CONVERT|FMT_FLAG_DOLLAR_MULTIPLE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_EMPTY_PREC_OK, | |
148 'w', 0, 'p', 0, 'L', 0, | |
149 &integer_type_node, &integer_type_node | |
150 }, | |
151 { "ms_scanf", ms_printf_length_specs, ms_scan_char_table, "*'", NULL, | |
152 ms_scanf_flag_specs, ms_scanf_flag_pairs, | |
153 FMT_FLAG_ARG_CONVERT|FMT_FLAG_SCANF_A_KLUDGE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_ZERO_WIDTH_BAD|FMT_FLAG_DOLLAR_GAP_POINTER_OK, | |
154 'w', 0, 0, '*', 'L', 0, | |
155 NULL, NULL | |
156 }, | |
157 { "ms_strftime", NULL, ms_time_char_table, "", "#", | |
158 ms_strftime_flag_specs, ms_strftime_flag_pairs, | |
159 FMT_FLAG_FANCY_PERCENT_OK, 0, 0, 0, 0, 0, 0, | |
160 NULL, NULL | |
161 } | |
162 }; | |
163 | |
164 /* 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
|
165 EXPORTED_CONST target_ovr_attr mingw_format_attribute_overrides[4] = |
0 | 166 { |
167 { "ms_printf", "printf" }, | |
168 { "ms_scanf", "scanf" }, | |
169 { "ms_strftime", "strftime" } | |
170 }; | |
171 | |
172 /* Setup for option Wpedantic-ms-format. */ | |
173 | |
174 #ifdef TARGET_OVERRIDES_FORMAT_INIT | |
175 | |
176 /* Make sure TARGET_OVERRIDES_FORMAT_INIT is prototyped. */ | |
177 extern void TARGET_OVERRIDES_FORMAT_INIT (void); | |
178 | |
179 /* Helper. */ | |
180 #define C89_OR_EXT (warn_pedantic_ms_format ? STD_EXT : STD_C89) | |
181 | |
182 void | |
183 TARGET_OVERRIDES_FORMAT_INIT (void) | |
184 { | |
185 ms_printf_length_specs[2].std = C89_OR_EXT; /* I32 */ | |
186 ms_printf_length_specs[3].std = C89_OR_EXT; /* I64 */ | |
187 ms_printf_length_specs[4].std = C89_OR_EXT; /* I */ | |
188 } | |
189 | |
190 #undef C89_OR_EXT | |
191 | |
192 #endif |