Mercurial > hg > CbC > CbC_gcc
annotate gcc/config/sol2-c.c @ 67:f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author | nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Mar 2011 17:18:12 +0900 |
parents | b7f97abdc517 |
children | 04ced10e8804 |
rev | line source |
---|---|
0 | 1 /* Solaris support needed only by C/C++ frontends. |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2 Copyright (C) 2004, 2005, 2007, 2009, 2010 Free Software Foundation, Inc. |
0 | 3 Contributed by CodeSourcery, LLC. |
4 | |
5 This file is part of GCC. | |
6 | |
7 GCC is free software; you can redistribute it and/or modify | |
8 it under the terms of the GNU General Public License as published by | |
9 the Free Software Foundation; either version 3, or (at your option) | |
10 any later version. | |
11 | |
12 GCC is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with GCC; see the file COPYING3. If not see | |
19 <http://www.gnu.org/licenses/>. */ | |
20 | |
21 #include "config.h" | |
22 #include "system.h" | |
23 #include "coretypes.h" | |
24 #include "tree.h" | |
25 #include "tm.h" | |
26 #include "tm_p.h" | |
27 | |
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 #include "intl.h" |
30 | |
31 #include "cpplib.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
|
32 #include "c-family/c-pragma.h" |
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
|
33 #include "c-family/c-common.h" |
0 | 34 |
35 /* cmn_err only accepts "l" and "ll". */ | |
36 static const format_length_info cmn_err_length_specs[] = | |
37 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
38 { "l", FMT_LEN_l, STD_C89, "ll", FMT_LEN_ll, 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
|
39 { NULL, FMT_LEN_none, STD_C89, NULL, FMT_LEN_none, STD_C89, 0 } |
0 | 40 }; |
41 | |
42 static const format_flag_spec cmn_err_flag_specs[] = | |
43 { | |
44 { 'w', 0, 0, N_("field width"), N_("field width in printf format"), STD_C89 }, | |
45 { 'L', 0, 0, N_("length modifier"), N_("length modifier in printf format"), STD_C89 }, | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
46 { 0, 0, 0, NULL, NULL, STD_C89 } |
0 | 47 }; |
48 | |
49 | |
50 static const format_flag_pair cmn_err_flag_pairs[] = | |
51 { | |
52 { 0, 0, 0, 0 } | |
53 }; | |
54 | |
55 static const format_char_info bitfield_string_type = | |
56 { "b", 1, STD_C89, { T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "cR", NULL }; | |
57 | |
58 static const format_char_info cmn_err_char_table[] = | |
59 { | |
60 /* C89 conversion specifiers. */ | |
61 { "dD", 0, STD_C89, { T89_I, BADLEN, BADLEN, T89_L, T9L_LL, BADLEN, BADLEN, BADLEN, BADLEN }, "w", "", NULL }, | |
62 { "oOxX",0, STD_C89, { T89_UI, BADLEN, BADLEN, T89_UL, T9L_ULL, BADLEN, BADLEN, BADLEN, BADLEN }, "w", "", NULL }, | |
63 { "u", 0, STD_C89, { T89_UI, BADLEN, BADLEN, T89_UL, T9L_ULL, BADLEN, BADLEN, BADLEN, BADLEN }, "w", "", NULL }, | |
64 { "c", 0, STD_C89, { T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "w", "", NULL }, | |
65 { "p", 1, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "w", "c", NULL }, | |
66 { "s", 1, STD_C89, { T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "w", "cR", NULL }, | |
67 { "b", 0, STD_C89, { T89_I, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "w", "", &bitfield_string_type }, | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
68 { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL } |
0 | 69 }; |
70 | |
71 const format_kind_info solaris_format_types[] = { | |
72 { "cmn_err", cmn_err_length_specs, cmn_err_char_table, "", NULL, | |
73 cmn_err_flag_specs, cmn_err_flag_pairs, | |
74 FMT_FLAG_ARG_CONVERT|FMT_FLAG_EMPTY_PREC_OK, | |
75 'w', 0, 0, 0, 'L', 0, | |
76 &integer_type_node, &integer_type_node | |
77 } | |
78 }; | |
79 | |
80 /* Handle #pragma align ALIGNMENT (VAR [, VAR]...) */ | |
81 | |
82 static void | |
83 solaris_pragma_align (cpp_reader *pfile ATTRIBUTE_UNUSED) | |
84 { | |
85 tree t, x; | |
86 enum cpp_ttype ttype; | |
87 HOST_WIDE_INT low; | |
88 | |
89 if (pragma_lex (&x) != CPP_NUMBER | |
90 || pragma_lex (&t) != CPP_OPEN_PAREN) | |
91 { | |
92 warning (0, "malformed %<#pragma align%>, ignoring"); | |
93 return; | |
94 } | |
95 | |
96 low = TREE_INT_CST_LOW (x); | |
97 if (TREE_INT_CST_HIGH (x) != 0 | |
98 || (low != 1 && low != 2 && low != 4 && low != 8 && low != 16 | |
99 && low != 32 && low != 64 && low != 128)) | |
100 { | |
101 warning (0, "invalid alignment for %<#pragma align%>, ignoring"); | |
102 return; | |
103 } | |
104 | |
105 ttype = pragma_lex (&t); | |
106 if (ttype != CPP_NAME) | |
107 { | |
108 warning (0, "malformed %<#pragma align%>, ignoring"); | |
109 return; | |
110 } | |
111 | |
112 while (1) | |
113 { | |
114 tree decl = identifier_global_value (t); | |
115 if (decl && DECL_P (decl)) | |
116 warning (0, "%<#pragma align%> must appear before the declaration of " | |
117 "%D, ignoring", decl); | |
118 else | |
119 solaris_pending_aligns = tree_cons (t, build_tree_list (NULL, x), | |
120 solaris_pending_aligns); | |
121 | |
122 ttype = pragma_lex (&t); | |
123 if (ttype == CPP_COMMA) | |
124 { | |
125 ttype = pragma_lex (&t); | |
126 if (ttype != CPP_NAME) | |
127 { | |
128 warning (0, "malformed %<#pragma align%>"); | |
129 return; | |
130 } | |
131 } | |
132 else if (ttype == CPP_CLOSE_PAREN) | |
133 { | |
134 if (pragma_lex (&t) != CPP_EOF) | |
135 warning (0, "junk at end of %<#pragma align%>"); | |
136 return; | |
137 } | |
138 else | |
139 { | |
140 warning (0, "malformed %<#pragma align%>"); | |
141 return; | |
142 } | |
143 } | |
144 } | |
145 | |
146 /* Handle #pragma init (function [, function]...) */ | |
147 | |
148 static void | |
149 solaris_pragma_init (cpp_reader *pfile ATTRIBUTE_UNUSED) | |
150 { | |
151 tree t; | |
152 enum cpp_ttype ttype; | |
153 | |
154 if (pragma_lex (&t) != CPP_OPEN_PAREN) | |
155 { | |
156 warning (0, "malformed %<#pragma init%>, ignoring"); | |
157 return; | |
158 } | |
159 | |
160 ttype = pragma_lex (&t); | |
161 if (ttype != CPP_NAME) | |
162 { | |
163 warning (0, "malformed %<#pragma init%>, ignoring"); | |
164 return; | |
165 } | |
166 | |
167 while (1) | |
168 { | |
169 tree decl = identifier_global_value (t); | |
170 if (decl && DECL_P (decl)) | |
171 { | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
172 tree attrs = build_tree_list (get_identifier ("init"), |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
173 NULL); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
174 TREE_USED (decl) = 1; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
175 DECL_PRESERVE_P (decl) = 1; |
0 | 176 decl_attributes (&decl, attrs, 0); |
177 } | |
178 else | |
179 solaris_pending_inits = tree_cons (t, NULL, solaris_pending_inits); | |
180 | |
181 ttype = pragma_lex (&t); | |
182 if (ttype == CPP_COMMA) | |
183 { | |
184 ttype = pragma_lex (&t); | |
185 if (ttype != CPP_NAME) | |
186 { | |
187 warning (0, "malformed %<#pragma init%>"); | |
188 return; | |
189 } | |
190 } | |
191 else if (ttype == CPP_CLOSE_PAREN) | |
192 { | |
193 if (pragma_lex (&t) != CPP_EOF) | |
194 warning (0, "junk at end of %<#pragma init%>"); | |
195 return; | |
196 } | |
197 else | |
198 { | |
199 warning (0, "malformed %<#pragma init%>"); | |
200 return; | |
201 } | |
202 } | |
203 } | |
204 | |
205 /* Handle #pragma fini (function [, function]...) */ | |
206 | |
207 static void | |
208 solaris_pragma_fini (cpp_reader *pfile ATTRIBUTE_UNUSED) | |
209 { | |
210 tree t; | |
211 enum cpp_ttype ttype; | |
212 | |
213 if (pragma_lex (&t) != CPP_OPEN_PAREN) | |
214 { | |
215 warning (0, "malformed %<#pragma fini%>, ignoring"); | |
216 return; | |
217 } | |
218 | |
219 ttype = pragma_lex (&t); | |
220 if (ttype != CPP_NAME) | |
221 { | |
222 warning (0, "malformed %<#pragma fini%>, ignoring"); | |
223 return; | |
224 } | |
225 | |
226 while (1) | |
227 { | |
228 tree decl = identifier_global_value (t); | |
229 if (decl && DECL_P (decl)) | |
230 { | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
231 tree attrs = build_tree_list (get_identifier ("fini"), |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
232 NULL); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
233 TREE_USED (decl) = 1; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
234 DECL_PRESERVE_P (decl) = 1; |
0 | 235 decl_attributes (&decl, attrs, 0); |
236 } | |
237 else | |
238 solaris_pending_finis = tree_cons (t, NULL, solaris_pending_finis); | |
239 | |
240 ttype = pragma_lex (&t); | |
241 if (ttype == CPP_COMMA) | |
242 { | |
243 ttype = pragma_lex (&t); | |
244 if (ttype != CPP_NAME) | |
245 { | |
246 warning (0, "malformed %<#pragma fini%>"); | |
247 return; | |
248 } | |
249 } | |
250 else if (ttype == CPP_CLOSE_PAREN) | |
251 { | |
252 if (pragma_lex (&t) != CPP_EOF) | |
253 warning (0, "junk at end of %<#pragma fini%>"); | |
254 return; | |
255 } | |
256 else | |
257 { | |
258 warning (0, "malformed %<#pragma fini%>"); | |
259 return; | |
260 } | |
261 } | |
262 } | |
263 | |
264 /* Register Solaris-specific #pragma directives. */ | |
265 | |
266 void | |
267 solaris_register_pragmas (void) | |
268 { | |
269 c_register_pragma_with_expansion (0, "align", solaris_pragma_align); | |
270 c_register_pragma (0, "init", solaris_pragma_init); | |
271 c_register_pragma (0, "fini", solaris_pragma_fini); | |
272 } |