aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndrew Haley <aph@redhat.com>2002-04-12 09:08:17 +0000
committerAndrew Haley <aph@gcc.gnu.org>2002-04-12 09:08:17 +0000
commit2f4d058f0ce572aa358ac3d1684ea0259577c049 (patch)
tree277b513c936234b5ad3914b83a548a527b16aa71 /gcc
parent4b4248b674fa9d34f2d5f7515761993849d804dd (diff)
downloadgcc-2f4d058f0ce572aa358ac3d1684ea0259577c049.zip
gcc-2f4d058f0ce572aa358ac3d1684ea0259577c049.tar.gz
gcc-2f4d058f0ce572aa358ac3d1684ea0259577c049.tar.bz2
typeck.c (type_after_usual_arithmetic_conversions): If two types have the same variant, return immediately.
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
Diffstat (limited to 'gcc')
-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);
}
}