1 /* Handle types for the GNU compiler for the Java(TM) language.
2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
3 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC 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 2, or (at your option)
12 GNU CC 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.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.
22 Java and all Java-based marks are trademarks or registered trademarks
23 of Sun Microsystems, Inc. in the United States and other countries.
24 The Free Software Foundation is independent of Sun Microsystems, Inc. */
26 /* Written by Per Bothner <bothner@cygnus.com> */
33 #include "java-tree.h"
39 static tree convert_ieee_real_to_integer PARAMS ((tree, tree));
40 static tree parse_signature_type PARAMS ((const unsigned char **,
41 const unsigned char *));
42 static tree lookup_do PARAMS ((tree, tree, tree, tree, tree (*)(tree)));
45 extern struct obstack permanent_obstack;
47 /* Set the type of the local variable with index SLOT to TYPE. */
50 set_local_type (slot, type)
54 int max_locals = DECL_MAX_LOCALS(current_function_decl);
55 int nslots = TYPE_IS_WIDE (type) ? 2 : 1;
57 if (slot < 0 || slot + nslots - 1 >= max_locals)
60 type_map[slot] = type;
62 type_map[++slot] = void_type_node;
65 /* Convert an IEEE real to an integer type. The result of such a
66 conversion when the source operand is a NaN isn't defined by
67 IEEE754, but by the Java language standard: it must be zero. Also,
68 overflows must be clipped to within range. This conversion
69 produces something like:
71 ((expr >= (float)MAX_INT)
73 : ((expr <= (float)MIN_INT)
80 convert_ieee_real_to_integer (type, expr)
84 expr = save_expr (expr);
86 result = build (COND_EXPR, type,
87 build (NE_EXPR, boolean_type_node, expr, expr),
88 convert (type, integer_zero_node),
89 convert_to_integer (type, expr));
91 result = build (COND_EXPR, type,
92 build (LE_EXPR, boolean_type_node, expr,
93 convert (TREE_TYPE (expr), TYPE_MIN_VALUE (type))),
94 TYPE_MIN_VALUE (type),
97 result = build (COND_EXPR, type,
98 build (GE_EXPR, boolean_type_node, expr,
99 convert (TREE_TYPE (expr), TYPE_MAX_VALUE (type))),
100 TYPE_MAX_VALUE (type),
106 /* Create an expression whose value is that of EXPR,
107 converted to type TYPE. The TREE_TYPE of the value
108 is always TYPE. This function implements all reasonable
109 conversions; callers should filter out those that are
110 not permitted by the language being compiled. */
116 register enum tree_code code = TREE_CODE (type);
119 return error_mark_node;
122 return build1 (NOP_EXPR, type, expr);
124 if (type == TREE_TYPE (expr)
125 || TREE_CODE (expr) == ERROR_MARK)
127 if (TREE_CODE (TREE_TYPE (expr)) == ERROR_MARK)
128 return error_mark_node;
129 if (code == VOID_TYPE)
130 return build1 (CONVERT_EXPR, type, expr);
131 if (code == BOOLEAN_TYPE)
132 return fold (convert_to_boolean (type, expr));
133 if (code == INTEGER_TYPE)
136 && ! flag_emit_class_files
137 && TREE_CODE (TREE_TYPE (expr)) == REAL_TYPE
138 && TARGET_FLOAT_FORMAT == IEEE_FLOAT_FORMAT)
139 return fold (convert_ieee_real_to_integer (type, expr));
141 return fold (convert_to_integer (type, expr));
143 if (code == REAL_TYPE)
144 return fold (convert_to_real (type, expr));
145 if (code == CHAR_TYPE)
146 return fold (convert_to_char (type, expr));
147 if (code == POINTER_TYPE)
148 return fold (convert_to_pointer (type, expr));
149 error ("conversion to non-scalar type requested");
150 return error_mark_node;
155 convert_to_char (type, expr)
158 return build1 (NOP_EXPR, type, expr);
162 convert_to_boolean (type, expr)
165 return build1 (NOP_EXPR, type, expr);
168 /* Print an error message for invalid use of an incomplete type.
169 VALUE is the expression that was used (or 0 if that isn't known)
170 and TYPE is the type that was invalid. */
173 incomplete_type_error (value, type)
174 tree value ATTRIBUTE_UNUSED;
175 tree type ATTRIBUTE_UNUSED;
177 error ("internal error - use of undefined type");
180 /* Return a data type that has machine mode MODE.
181 If the mode is an integer,
182 then UNSIGNEDP selects between signed and unsigned types. */
185 type_for_mode (mode, unsignedp)
186 enum machine_mode mode;
189 if (mode == TYPE_MODE (int_type_node))
190 return unsignedp ? unsigned_int_type_node : int_type_node;
191 if (mode == TYPE_MODE (long_type_node))
192 return unsignedp ? unsigned_long_type_node : long_type_node;
193 if (mode == TYPE_MODE (short_type_node))
194 return unsignedp ? unsigned_short_type_node : short_type_node;
195 if (mode == TYPE_MODE (byte_type_node))
196 return unsignedp ? unsigned_byte_type_node : byte_type_node;
197 if (mode == TYPE_MODE (float_type_node))
198 return float_type_node;
199 if (mode == TYPE_MODE (double_type_node))
200 return double_type_node;
205 /* Return an integer type with BITS bits of precision,
206 that is unsigned if UNSIGNEDP is nonzero, otherwise signed. */
209 type_for_size (bits, unsignedp)
213 if (bits <= TYPE_PRECISION (byte_type_node))
214 return unsignedp ? unsigned_byte_type_node : byte_type_node;
215 if (bits <= TYPE_PRECISION (short_type_node))
216 return unsignedp ? unsigned_short_type_node : short_type_node;
217 if (bits <= TYPE_PRECISION (int_type_node))
218 return unsignedp ? unsigned_int_type_node : int_type_node;
219 if (bits <= TYPE_PRECISION (long_type_node))
220 return unsignedp ? unsigned_long_type_node : long_type_node;
224 /* Return a type the same as TYPE except unsigned or
225 signed according to UNSIGNEDP. */
228 signed_or_unsigned_type (unsignedp, type)
232 if (! INTEGRAL_TYPE_P (type))
234 if (TYPE_PRECISION (type) == TYPE_PRECISION (int_type_node))
235 return unsignedp ? unsigned_int_type_node : int_type_node;
236 if (TYPE_PRECISION (type) == TYPE_PRECISION (byte_type_node))
237 return unsignedp ? unsigned_byte_type_node : byte_type_node;
238 if (TYPE_PRECISION (type) == TYPE_PRECISION (short_type_node))
239 return unsignedp ? unsigned_short_type_node : short_type_node;
240 if (TYPE_PRECISION (type) == TYPE_PRECISION (long_type_node))
241 return unsignedp ? unsigned_long_type_node : long_type_node;
245 /* Return a signed type the same as TYPE in other respects. */
251 return signed_or_unsigned_type (0, type);
254 /* Return an unsigned type the same as TYPE in other respects. */
260 return signed_or_unsigned_type (1, type);
264 /* Mark EXP saying that we need to be able to take the
265 address of it; it should not be allocated in a register.
266 Value is 1 if successful. */
269 mark_addressable (exp)
272 register tree x = exp;
274 switch (TREE_CODE (x))
281 x = TREE_OPERAND (x, 0);
284 case TRUTH_ANDIF_EXPR:
285 case TRUTH_ORIF_EXPR:
287 x = TREE_OPERAND (x, 1);
291 return mark_addressable (TREE_OPERAND (x, 1))
292 & mark_addressable (TREE_OPERAND (x, 2));
295 TREE_ADDRESSABLE (x) = 1;
299 /* We sometimes add a cast *(TYPE*)&FOO to handle type and mode
300 incompatibility problems. Handle this case by marking FOO. */
301 if (TREE_CODE (TREE_OPERAND (x, 0)) == NOP_EXPR
302 && TREE_CODE (TREE_OPERAND (TREE_OPERAND (x, 0), 0)) == ADDR_EXPR)
304 x = TREE_OPERAND (TREE_OPERAND (x, 0), 0);
307 if (TREE_CODE (TREE_OPERAND (x, 0)) == ADDR_EXPR)
309 x = TREE_OPERAND (x, 0);
319 TREE_ADDRESSABLE (x) = 1;
320 #if 0 /* poplevel deals with this now. */
321 if (DECL_CONTEXT (x) == 0)
322 TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (x)) = 1;
330 /* Thorough checking of the arrayness of TYPE. */
333 is_array_type_p (type)
336 return TREE_CODE (type) == POINTER_TYPE
337 && TREE_CODE (TREE_TYPE (type)) == RECORD_TYPE
338 && TYPE_ARRAY_P (TREE_TYPE (type));
341 /* Return the length of a Java array type.
342 Return -1 if the length is unknown or non-constant. */
345 java_array_type_length (array_type)
349 if (TREE_CODE (array_type) == POINTER_TYPE)
350 array_type = TREE_TYPE (array_type);
351 arfld = TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (array_type)));
352 if (arfld != NULL_TREE)
354 tree index_type = TYPE_DOMAIN (TREE_TYPE (arfld));
355 tree high = TYPE_MAX_VALUE (index_type);
356 if (TREE_CODE (high) == INTEGER_CST)
357 return TREE_INT_CST_LOW (high) + 1;
362 /* An array of unknown length will be ultimately given an length of
363 -2, so that we can still have `length' producing a negative value
364 even if found. This was part of an optimization amaing at removing
365 `length' from static arrays. We could restore it, FIXME. */
368 build_prim_array_type (element_type, length)
370 HOST_WIDE_INT length;
372 tree max_index = build_int_2 (length - 1, (0 == length ? -1 : 0));
373 TREE_TYPE (max_index) = sizetype;
374 return build_array_type (element_type, build_index_type (max_index));
377 /* Return a Java array type with a given ELEMENT_TYPE and LENGTH.
378 These are hashed (shared) using IDENTIFIER_SIGNATURE_TYPE.
379 The LENGTH is -1 if the length is unknown. */
382 build_java_array_type (element_type, length)
384 HOST_WIDE_INT length;
386 tree sig, t, fld, atype, arfld;
388 tree elsig = build_java_signature (element_type);
389 tree el_name = element_type;
392 sprintf (buf+1, HOST_WIDE_INT_PRINT_DEC, length);
395 sig = ident_subst (IDENTIFIER_POINTER (elsig), IDENTIFIER_LENGTH (elsig),
397 t = IDENTIFIER_SIGNATURE_TYPE (sig);
399 return TREE_TYPE (t);
401 IDENTIFIER_SIGNATURE_TYPE (sig) = build_pointer_type (t);
402 TYPE_ARRAY_P (t) = 1;
404 if (TREE_CODE (el_name) == POINTER_TYPE)
405 el_name = TREE_TYPE (el_name);
406 el_name = TYPE_NAME (el_name);
407 if (TREE_CODE (el_name) == TYPE_DECL)
408 el_name = DECL_NAME (el_name);
409 TYPE_NAME (t) = identifier_subst (el_name, "", '.', '.', "[]");
411 set_java_signature (t, sig);
412 set_super_info (0, t, object_type_node, 0);
413 if (TREE_CODE (element_type) == RECORD_TYPE)
414 element_type = promote_type (element_type);
415 TYPE_ARRAY_ELEMENT (t) = element_type;
417 /* Add length pseudo-field. */
418 fld = build_decl (FIELD_DECL, get_identifier ("length"), int_type_node);
419 TYPE_FIELDS (t) = fld;
420 DECL_CONTEXT (fld) = t;
421 FIELD_PUBLIC (fld) = 1;
422 FIELD_FINAL (fld) = 1;
424 atype = build_prim_array_type (element_type, length);
425 arfld = build_decl (FIELD_DECL, get_identifier ("data"), atype);
426 DECL_CONTEXT (arfld) = t;
427 TREE_CHAIN (fld) = arfld;
428 DECL_ALIGN (arfld) = TYPE_ALIGN (element_type);
430 /* We could layout_class, but that loads java.lang.Object prematurely.
431 * This is called by the parser, and it is a bad idea to do load_class
432 * in the middle of parsing, because of possible circularity problems. */
433 push_super_field (t, object_type_node);
439 /* Promote TYPE to the type actually used for fields and parameters. */
445 switch (TREE_CODE (type))
448 return build_pointer_type (CLASS_TO_HANDLE_TYPE (type));
450 if (type == boolean_type_node)
451 return promoted_boolean_type_node;
454 if (type == char_type_node)
455 return promoted_char_type_node;
459 if (TYPE_PRECISION (type) < TYPE_PRECISION (int_type_node))
461 if (type == short_type_node)
462 return promoted_short_type_node;
463 if (type == byte_type_node)
464 return promoted_byte_type_node;
465 return int_type_node;
467 /* ... else fall through ... */
473 /* Parse a signature string, starting at *PTR and ending at LIMIT.
474 Return the seen TREE_TYPE, updating *PTR. */
477 parse_signature_type (ptr, limit)
478 const unsigned char **ptr, *limit;
487 case 'B': (*ptr)++; return byte_type_node;
488 case 'C': (*ptr)++; return char_type_node;
489 case 'D': (*ptr)++; return double_type_node;
490 case 'F': (*ptr)++; return float_type_node;
491 case 'S': (*ptr)++; return short_type_node;
492 case 'I': (*ptr)++; return int_type_node;
493 case 'J': (*ptr)++; return long_type_node;
494 case 'Z': (*ptr)++; return boolean_type_node;
495 case 'V': (*ptr)++; return void_type_node;
497 for ((*ptr)++; (*ptr) < limit && ISDIGIT (**ptr); ) (*ptr)++;
498 type = parse_signature_type (ptr, limit);
499 type = build_java_array_type (type, -1);
503 const unsigned char *start = ++(*ptr);
504 register const unsigned char *str = start;
513 type = lookup_class (unmangle_classname (start, str - start));
519 return promote_type (type);
522 /* Parse a Java "mangled" signature string, starting at SIG_STRING,
523 and SIG_LENGTH bytes long.
524 Return a gcc type node. */
527 parse_signature_string (sig_string, sig_length)
528 const unsigned char *sig_string;
532 const unsigned char *str = sig_string;
533 const unsigned char *limit = str + sig_length;
535 if (str < limit && str[0] == '(')
537 tree argtype_list = NULL_TREE;
539 while (str < limit && str[0] != ')')
541 tree argtype = parse_signature_type (&str, limit);
542 argtype_list = tree_cons (NULL_TREE, argtype, argtype_list);
544 if (str++, str >= limit)
546 result_type = parse_signature_type (&str, limit);
547 argtype_list = chainon (nreverse (argtype_list), end_params_node);
548 result_type = build_function_type (result_type, argtype_list);
551 result_type = parse_signature_type (&str, limit);
553 error ("junk at end of signature string");
557 /* Convert a signature to its type.
558 * Uses IDENTIFIER_SIGNATURE_TYPE as a cache (except for primitive types).
562 get_type_from_signature (tree signature)
564 const unsigned char *sig = (const unsigned char *) IDENTIFIER_POINTER (signature);
565 int len = IDENTIFIER_LENGTH (signature);
567 /* Primitive types aren't cached. */
569 return parse_signature_string (sig, len);
570 type = IDENTIFIER_SIGNATURE_TYPE (signature);
571 if (type == NULL_TREE)
573 type = parse_signature_string (sig, len);
574 IDENTIFIER_SIGNATURE_TYPE (signature) = type;
579 /* Return the signature string for the arguments of method type TYPE. */
582 build_java_argument_signature (type)
585 extern struct obstack temporary_obstack;
586 tree sig = TYPE_ARGUMENT_SIGNATURE (type);
587 if (sig == NULL_TREE)
589 tree args = TYPE_ARG_TYPES (type);
590 if (TREE_CODE (type) == METHOD_TYPE)
591 args = TREE_CHAIN (args); /* Skip "this" argument. */
592 for (; args != end_params_node; args = TREE_CHAIN (args))
594 tree t = build_java_signature (TREE_VALUE (args));
595 obstack_grow (&temporary_obstack,
596 IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t));
598 obstack_1grow (&temporary_obstack, '\0');
600 sig = get_identifier (obstack_base (&temporary_obstack));
601 TYPE_ARGUMENT_SIGNATURE (type) = sig;
602 obstack_free (&temporary_obstack, obstack_base (&temporary_obstack));
607 /* Return the signature of the given TYPE. */
610 build_java_signature (type)
614 while (TREE_CODE (type) == POINTER_TYPE)
615 type = TREE_TYPE (type);
616 MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type);
617 sig = TYPE_SIGNATURE (type);
618 if (sig == NULL_TREE)
621 switch (TREE_CODE (type))
623 case BOOLEAN_TYPE: sg[0] = 'Z'; goto native;
624 case CHAR_TYPE: sg[0] = 'C'; goto native;
625 case VOID_TYPE: sg[0] = 'V'; goto native;
627 switch (TYPE_PRECISION (type))
629 case 8: sg[0] = 'B'; goto native;
630 case 16: sg[0] = 'S'; goto native;
631 case 32: sg[0] = 'I'; goto native;
632 case 64: sg[0] = 'J'; goto native;
633 default: goto bad_type;
636 switch (TYPE_PRECISION (type))
638 case 32: sg[0] = 'F'; goto native;
639 case 64: sg[0] = 'D'; goto native;
640 default: goto bad_type;
644 sig = get_identifier (sg);
647 if (TYPE_ARRAY_P (type))
649 t = build_java_signature (TYPE_ARRAY_ELEMENT (type));
650 sig = ident_subst (IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t),
655 t = DECL_NAME (TYPE_NAME (type));
656 sig = ident_subst (IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t),
663 extern struct obstack temporary_obstack;
664 sig = build_java_argument_signature (type);
665 obstack_1grow (&temporary_obstack, '(');
666 obstack_grow (&temporary_obstack,
667 IDENTIFIER_POINTER (sig), IDENTIFIER_LENGTH (sig));
668 obstack_1grow (&temporary_obstack, ')');
670 t = build_java_signature (TREE_TYPE (type));
671 obstack_grow0 (&temporary_obstack,
672 IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t));
674 sig = get_identifier (obstack_base (&temporary_obstack));
675 obstack_free (&temporary_obstack,
676 obstack_base (&temporary_obstack));
683 TYPE_SIGNATURE (type) = sig;
688 /* Save signature string SIG (an IDENTIFIER_NODE) in TYPE for future use. */
691 set_java_signature (type, sig)
696 while (TREE_CODE (type) == POINTER_TYPE)
697 type = TREE_TYPE (type);
698 MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type);
699 old_sig = TYPE_SIGNATURE (type);
700 if (old_sig != NULL_TREE && old_sig != sig)
702 TYPE_SIGNATURE (type) = sig;
703 #if 0 /* careful about METHOD_TYPE */
704 if (IDENTIFIER_SIGNATURE_TYPE (sig) == NULL_TREE && TREE_PERMANENT (type))
705 IDENTIFIER_SIGNATURE_TYPE (sig) = type;
709 /* Search in class SEARCHED_CLASS (and its superclasses) for a method
710 matching METHOD_NAME and signature SIGNATURE. If SEARCHED_INTERFACE is
711 not NULL_TREE then first search its superinterfaces for a similar match.
712 Return the matched method DECL or NULL_TREE. SIGNATURE_BUILDER is
713 used on method candidates to build their (sometimes partial)
717 lookup_argument_method (searched_class, method_name, method_signature)
718 tree searched_class, method_name, method_signature;
720 return lookup_do (searched_class, NULL_TREE, method_name, method_signature,
721 build_java_argument_signature);
724 /* Search in class SEARCHED_CLASS (and its superclasses and
725 implemented interfaces) for a method matching METHOD_NAME and
726 argument signature METHOD_SIGNATURE. Return a FUNCTION_DECL on
727 success, or NULL_TREE if none found. (Contrast lookup_java_method,
728 which takes into account return type.) */
731 lookup_argument_method2 (searched_class, method_name, method_signature)
732 tree searched_class, method_name, method_signature;
734 return lookup_do (CLASSTYPE_SUPER (searched_class), searched_class,
735 method_name, method_signature,
736 build_java_argument_signature);
739 /* Search in class SEARCHED_CLASS (and its superclasses) for a method
740 matching METHOD_NAME and signature METHOD_SIGNATURE. Return a
741 FUNCTION_DECL on success, or NULL_TREE if none found. (Contrast
742 lookup_argument_method, which ignores return type.) If
743 SEARCHED_CLASS is an interface, search it too. */
746 lookup_java_method (searched_class, method_name, method_signature)
747 tree searched_class, method_name, method_signature;
749 tree searched_interface;
751 /* If this class is an interface class, search its superinterfaces
752 * first. A superinterface is not an interface's superclass: a super
753 * interface is implemented by the interface. */
755 searched_interface = (CLASS_INTERFACE (TYPE_NAME (searched_class)) ?
756 searched_class : NULL_TREE);
757 return lookup_do (searched_class, searched_interface, method_name,
758 method_signature, build_java_signature);
761 /* Search in class SEARCHED_CLASS (an its superclasses) for a method
762 matching METHOD_NAME and signature SIGNATURE. Also search in
763 SEARCHED_INTERFACE (an its superinterfaces) for a similar match.
764 Return the matched method DECL or NULL_TREE. SIGNATURE_BUILDER is
765 used on method candidates to build their (sometimes partial)
769 lookup_do (searched_class, searched_interface, method_name, signature, signature_builder)
770 tree searched_class, searched_interface, method_name, signature;
771 tree (*signature_builder) PARAMS ((tree));
775 if (searched_interface)
779 TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (searched_interface)) - 1;
781 for (i = interface_len; i > 0; i--)
784 TREE_VEC_ELT (TYPE_BINFO_BASETYPES (searched_interface), i);
785 tree iclass = BINFO_TYPE (child);
787 /* If the superinterface hasn't been loaded yet, do so now. */
788 if (CLASS_FROM_SOURCE_P (iclass))
789 safe_layout_class (iclass);
790 else if (!CLASS_LOADED_P (iclass))
791 load_class (iclass, 1);
793 for (method = TYPE_METHODS (iclass);
794 method != NULL_TREE; method = TREE_CHAIN (method))
796 tree method_sig = (*signature_builder) (TREE_TYPE (method));
798 if (DECL_NAME (method) == method_name && method_sig == signature)
802 /* it could be defined in a supersuperinterface */
803 if (CLASS_INTERFACE (TYPE_NAME (iclass)))
805 method = lookup_do (iclass, iclass, method_name,
806 signature, signature_builder);
807 if (method != NULL_TREE)
813 while (searched_class != NULL_TREE)
815 for (method = TYPE_METHODS (searched_class);
816 method != NULL_TREE; method = TREE_CHAIN (method))
818 tree method_sig = (*signature_builder) (TREE_TYPE (method));
819 if (DECL_NAME (method) == method_name && method_sig == signature)
822 searched_class = CLASSTYPE_SUPER (searched_class);
828 /* Search in class CLAS for a constructor matching METHOD_SIGNATURE.
829 Return a FUNCTION_DECL on success, or NULL_TREE if none found. */
832 lookup_java_constructor (clas, method_signature)
833 tree clas, method_signature;
835 tree method = TYPE_METHODS (clas);
836 for ( ; method != NULL_TREE; method = TREE_CHAIN (method))
838 tree method_sig = build_java_signature (TREE_TYPE (method));
839 if (DECL_CONSTRUCTOR_P (method) && method_sig == method_signature)
845 /* Return a type which is the Binary Numeric Promotion of the pair T1,
846 T2 and convert EXP1 and/or EXP2. See 5.6.2 Binary Numeric
847 Promotion. It assumes that both T1 and T2 are eligible to BNP. */
850 binary_numeric_promotion (t1, t2, exp1, exp2)
856 if (t1 == double_type_node || t2 == double_type_node)
858 if (t1 != double_type_node)
859 *exp1 = convert (double_type_node, *exp1);
860 if (t2 != double_type_node)
861 *exp2 = convert (double_type_node, *exp2);
862 return double_type_node;
864 if (t1 == float_type_node || t2 == float_type_node)
866 if (t1 != float_type_node)
867 *exp1 = convert (float_type_node, *exp1);
868 if (t2 != float_type_node)
869 *exp2 = convert (float_type_node, *exp2);
870 return float_type_node;
872 if (t1 == long_type_node || t2 == long_type_node)
874 if (t1 != long_type_node)
875 *exp1 = convert (long_type_node, *exp1);
876 if (t2 != long_type_node)
877 *exp2 = convert (long_type_node, *exp2);
878 return long_type_node;
881 if (t1 != int_type_node)
882 *exp1 = convert (int_type_node, *exp1);
883 if (t2 != int_type_node)
884 *exp2 = convert (int_type_node, *exp2);
885 return int_type_node;