typeck.c (type_after_usual_arithmetic_conversions): If two types have the same varian...
authorAndrew Haley <aph@redhat.com>
Fri, 12 Apr 2002 09:08:17 +0000 (09:08 +0000)
committerAndrew Haley <aph@gcc.gnu.org>
Fri, 12 Apr 2002 09:08:17 +0000 (09:08 +0000)
2002-04-11  Andrew Haley  <aph@redhat.com>

* typeck.c (type_after_usual_arithmetic_conversions):
If two types have the same variant, return immediately.
When two floating-point operands are the same precision:
  convert to float if one of the operands is float;
  if neither operand is one of the standard types, return the type
  of the first operand.

From-SVN: r52209

gcc/cp/ChangeLog
gcc/cp/typeck.c

index a2d8b8f394338c1f28e53bdf1575e1ccb11d615b..439a3fcb46235b94abf08c3d5b06697c4d11887d 100644 (file)
@@ -1,3 +1,12 @@
+2002-04-11  Andrew Haley  <aph@redhat.com>
+
+       * typeck.c (type_after_usual_arithmetic_conversions):
+       If two types have the same variant, return immediately.
+       When two floating-point operands are the same precision: 
+         convert to float if one of the operands is float;
+         if neither operand is one of the standard types, return the type
+         of the first operand.
 2002-04-10  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/5507
index be07b2e457f3361354dcc43f6199cac2943c0732..7ccbee9cf2abb5d37d45208404a60fb3c6d02b38 100644 (file)
@@ -381,6 +381,10 @@ type_after_usual_arithmetic_conversions (t1, t2)
   else if (TYPE_PRECISION (t2) > TYPE_PRECISION (t1))
     return build_type_attribute_variant (t2, attributes);
 
+  /* The types are the same; no need to do anything fancy.  */
+  if (TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2))
+    return build_type_attribute_variant (t1, attributes);
+
   if (code1 != REAL_TYPE)
     {
       /* If one is a sizetype, use it so size_binop doesn't blow up.  */
@@ -442,9 +446,17 @@ type_after_usual_arithmetic_conversions (t1, t2)
          || same_type_p (TYPE_MAIN_VARIANT (t2), double_type_node))
        return build_type_attribute_variant (double_type_node,
                                             attributes);
-      else 
+      if (same_type_p (TYPE_MAIN_VARIANT (t1), float_type_node)
+         || same_type_p (TYPE_MAIN_VARIANT (t2), float_type_node))
        return build_type_attribute_variant (float_type_node,
                                             attributes);
+      
+      /* Two floating-point types whose TYPE_MAIN_VARIANTs are none of
+         the standard C++ floating-point types.  Logic earlier in this
+         function has already eliminated the possibility that
+         TYPE_PRECISION (t2) != TYPE_PRECISION (t1), so there's no
+         compelling reason to choose one or the other.  */
+      return build_type_attribute_variant (t1, attributes);
     }
 }