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
This commit is contained in:
Andrew Haley 2002-04-12 09:08:17 +00:00 committed by Andrew Haley
parent 4b4248b674
commit 2f4d058f0c
2 changed files with 22 additions and 1 deletions

View 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

View 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);
}
}