remove spurious code
[official-gcc.git] / gcc / ch / xtypeck.c
blob3534bc95d5b85d8e54f71f0212dfd13af838729c
1 /* Copyright (C) 1992, 1993, 1994, 1998 Free Software Foundation, Inc.
3 This file is part of GNU CC.
5 GNU CC is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
10 GNU CC is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNU CC; see the file COPYING. If not, write to
17 the Free Software Foundation, 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
21 #if 0
22 tree
23 build_component_ref (datum, field_name)
24 tree datum, field_name;
26 return build_chill_component_ref (datum, field_name);
29 /* Mark EXP saying that we need to be able to take the
30 address of it; it should not be allocated in a register.
31 Value is 1 if successful. */
33 int
34 mark_addressable (exp)
35 tree exp;
37 register tree x = exp;
38 while (1)
39 switch (TREE_CODE (x))
41 case ADDR_EXPR:
42 case COMPONENT_REF:
43 case ARRAY_REF:
44 case REALPART_EXPR:
45 case IMAGPART_EXPR:
46 x = TREE_OPERAND (x, 0);
47 break;
49 case CONSTRUCTOR:
50 TREE_ADDRESSABLE (x) = 1;
51 return 1;
53 case VAR_DECL:
54 case CONST_DECL:
55 case PARM_DECL:
56 case RESULT_DECL:
57 if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x)
58 && DECL_NONLOCAL (x))
60 if (TREE_PUBLIC (x))
62 error ("global register variable `%s' used in nested function",
63 IDENTIFIER_POINTER (DECL_NAME (x)));
64 return 0;
66 pedwarn ("register variable `%s' used in nested function",
67 IDENTIFIER_POINTER (DECL_NAME (x)));
69 else if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x))
71 if (TREE_PUBLIC (x))
73 error ("address of global register variable `%s' requested",
74 IDENTIFIER_POINTER (DECL_NAME (x)));
75 return 0;
78 /* If we are making this addressable due to its having
79 volatile components, give a different error message. Also
80 handle the case of an unnamed parameter by not trying
81 to give the name. */
83 else if (C_TYPE_FIELDS_VOLATILE (TREE_TYPE (x)))
85 error ("cannot put object with volatile field into register");
86 return 0;
89 pedwarn ("address of register variable `%s' requested",
90 IDENTIFIER_POINTER (DECL_NAME (x)));
92 put_var_into_stack (x);
94 /* drops in */
95 case FUNCTION_DECL:
96 TREE_ADDRESSABLE (x) = 1;
97 #if 0 /* poplevel deals with this now. */
98 if (DECL_CONTEXT (x) == 0)
99 TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (x)) = 1;
100 #endif
102 default:
103 return 1;
107 /* Return an unsigned type the same as TYPE in other respects. */
109 tree
110 unsigned_type (type)
111 tree type;
113 tree type1 = TYPE_MAIN_VARIANT (type);
114 if (type1 == signed_char_type_node || type1 == char_type_node)
115 return unsigned_char_type_node;
116 if (type1 == integer_type_node)
117 return unsigned_type_node;
118 if (type1 == short_integer_type_node)
119 return short_unsigned_type_node;
120 if (type1 == long_integer_type_node)
121 return long_unsigned_type_node;
122 if (type1 == long_long_integer_type_node)
123 return long_long_unsigned_type_node;
124 return type;
127 /* Return a signed type the same as TYPE in other respects. */
129 tree
130 signed_type (type)
131 tree type;
133 tree type1 = TYPE_MAIN_VARIANT (type);
134 if (type1 == unsigned_char_type_node || type1 == char_type_node)
135 return signed_char_type_node;
136 if (type1 == unsigned_type_node)
137 return integer_type_node;
138 if (type1 == short_unsigned_type_node)
139 return short_integer_type_node;
140 if (type1 == long_unsigned_type_node)
141 return long_integer_type_node;
142 if (type1 == long_long_unsigned_type_node)
143 return long_long_integer_type_node;
144 return type;
147 /* Return a type the same as TYPE except unsigned or
148 signed according to UNSIGNEDP. */
150 tree
151 signed_or_unsigned_type (unsignedp, type)
152 int unsignedp;
153 tree type;
155 if (! INTEGRAL_TYPE_P (type))
156 return type;
157 if (TYPE_PRECISION (type) == TYPE_PRECISION (signed_char_type_node))
158 return unsignedp ? unsigned_char_type_node : signed_char_type_node;
159 if (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
160 return unsignedp ? unsigned_type_node : integer_type_node;
161 if (TYPE_PRECISION (type) == TYPE_PRECISION (short_integer_type_node))
162 return unsignedp ? short_unsigned_type_node : short_integer_type_node;
163 if (TYPE_PRECISION (type) == TYPE_PRECISION (long_integer_type_node))
164 return unsignedp ? long_unsigned_type_node : long_integer_type_node;
165 if (TYPE_PRECISION (type) == TYPE_PRECISION (long_long_integer_type_node))
166 return (unsignedp ? long_long_unsigned_type_node
167 : long_long_integer_type_node);
168 return type;
171 extern tree intHI_type_node;
172 extern tree intSI_type_node;
173 extern tree intDI_type_node;
175 extern tree unsigned_intHI_type_node;
176 extern tree unsigned_intSI_type_node;
177 extern tree unsigned_intDI_type_node;
179 /* Return an integer type with BITS bits of precision,
180 that is unsigned if UNSIGNEDP is nonzero, otherwise signed. */
182 tree
183 type_for_size (bits, unsignedp)
184 unsigned bits;
185 int unsignedp;
187 if (bits == TYPE_PRECISION (signed_char_type_node))
188 return unsignedp ? unsigned_char_type_node : signed_char_type_node;
190 if (bits == TYPE_PRECISION (short_integer_type_node))
191 return unsignedp ? short_unsigned_type_node : short_integer_type_node;
193 if (bits == TYPE_PRECISION (integer_type_node))
194 return unsignedp ? unsigned_type_node : integer_type_node;
196 if (bits == TYPE_PRECISION (long_integer_type_node))
197 return unsignedp ? long_unsigned_type_node : long_integer_type_node;
199 if (bits == TYPE_PRECISION (long_long_integer_type_node))
200 return (unsignedp ? long_long_unsigned_type_node
201 : long_long_integer_type_node);
203 if (bits <= TYPE_PRECISION (intHI_type_node))
204 return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
206 if (bits <= TYPE_PRECISION (intSI_type_node))
207 return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
209 if (bits <= TYPE_PRECISION (intDI_type_node))
210 return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
212 return 0;
215 /* Return a data type that has machine mode MODE.
216 If the mode is an integer,
217 then UNSIGNEDP selects between signed and unsigned types. */
219 tree
220 type_for_mode (mode, unsignedp)
221 enum machine_mode mode;
222 int unsignedp;
224 if (mode == TYPE_MODE (signed_char_type_node))
225 return unsignedp ? unsigned_char_type_node : signed_char_type_node;
227 if (mode == TYPE_MODE (short_integer_type_node))
228 return unsignedp ? short_unsigned_type_node : short_integer_type_node;
230 if (mode == TYPE_MODE (integer_type_node))
231 return unsignedp ? unsigned_type_node : integer_type_node;
233 if (mode == TYPE_MODE (long_integer_type_node))
234 return unsignedp ? long_unsigned_type_node : long_integer_type_node;
236 if (mode == TYPE_MODE (long_long_integer_type_node))
237 return unsignedp ? long_long_unsigned_type_node : long_long_integer_type_node;
239 if (mode == TYPE_MODE (intHI_type_node))
240 return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
242 if (mode == TYPE_MODE (intSI_type_node))
243 return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
245 if (mode == TYPE_MODE (intDI_type_node))
246 return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
248 if (mode == TYPE_MODE (float_type_node))
249 return float_type_node;
251 if (mode == TYPE_MODE (double_type_node))
252 return double_type_node;
254 if (mode == TYPE_MODE (long_double_type_node))
255 return long_double_type_node;
257 if (mode == TYPE_MODE (build_pointer_type (char_type_node)))
258 return build_pointer_type (char_type_node);
260 if (mode == TYPE_MODE (build_pointer_type (integer_type_node)))
261 return build_pointer_type (integer_type_node);
263 return 0;
266 tree
267 truthvalue_conversion (expr)
268 tree expr;
270 return chill_truthvalue_conversion (expr);
272 #endif