aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/typeck.c14
2 files changed, 22 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a2d8b8f..439a3fc 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index be07b2e..7ccbee9 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -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);
}
}