tree etype = TREE_TYPE (expr);
enum tree_code ecode = TREE_CODE (etype);
enum tree_code code = TREE_CODE (type);
+ const bool ebiased
+ = (ecode == INTEGER_TYPE && TYPE_BIASED_REPRESENTATION_P (etype));
+ const bool biased
+ = (code == INTEGER_TYPE && TYPE_BIASED_REPRESENTATION_P (type));
+ const bool ereverse
+ = (AGGREGATE_TYPE_P (etype) && TYPE_REVERSE_STORAGE_ORDER (etype));
+ const bool reverse
+ = (AGGREGATE_TYPE_P (type) && TYPE_REVERSE_STORAGE_ORDER (type));
tree tem;
- int c;
+ int c = 0;
/* If the expression is already of the right type, we are done. */
if (etype == type)
|| (ecode == RECORD_TYPE && TYPE_JUSTIFIED_MODULAR_P (etype))))
|| code == UNCONSTRAINED_ARRAY_TYPE)
{
- if (ecode == INTEGER_TYPE && TYPE_BIASED_REPRESENTATION_P (etype))
+ if (ebiased)
{
tree ntype = copy_type (etype);
TYPE_BIASED_REPRESENTATION_P (ntype) = 0;
expr = build1 (NOP_EXPR, ntype, expr);
}
- if (code == INTEGER_TYPE && TYPE_BIASED_REPRESENTATION_P (type))
+ if (biased)
{
tree rtype = copy_type (type);
TYPE_BIASED_REPRESENTATION_P (rtype) = 0;
Finally, for the sake of consistency, we do the unchecked conversion
to an integral type with reverse storage order as soon as the source
type is an aggregate type with reverse storage order, even if there
- are no considerations of precision or size involved. */
- else if (INTEGRAL_TYPE_P (type)
- && TYPE_RM_SIZE (type)
- && (tree_int_cst_compare (TYPE_RM_SIZE (type),
- TYPE_SIZE (type)) < 0
- || (AGGREGATE_TYPE_P (etype)
- && TYPE_REVERSE_STORAGE_ORDER (etype))))
+ are no considerations of precision or size involved. Ultimately, we
+ further extend this processing to any scalar type. */
+ else if ((INTEGRAL_TYPE_P (type)
+ && TYPE_RM_SIZE (type)
+ && ((c = tree_int_cst_compare (TYPE_RM_SIZE (type),
+ TYPE_SIZE (type))) < 0
+ || ereverse))
+ || (SCALAR_FLOAT_TYPE_P (type) && ereverse))
{
tree rec_type = make_node (RECORD_TYPE);
- unsigned HOST_WIDE_INT prec = TREE_INT_CST_LOW (TYPE_RM_SIZE (type));
tree field_type, field;
- if (AGGREGATE_TYPE_P (etype))
- TYPE_REVERSE_STORAGE_ORDER (rec_type)
- = TYPE_REVERSE_STORAGE_ORDER (etype);
+ TYPE_REVERSE_STORAGE_ORDER (rec_type) = ereverse;
- if (type_unsigned_for_rm (type))
- field_type = make_unsigned_type (prec);
+ if (c < 0)
+ {
+ const unsigned HOST_WIDE_INT prec
+ = TREE_INT_CST_LOW (TYPE_RM_SIZE (type));
+ if (type_unsigned_for_rm (type))
+ field_type = make_unsigned_type (prec);
+ else
+ field_type = make_signed_type (prec);
+ SET_TYPE_RM_SIZE (field_type, TYPE_RM_SIZE (type));
+ }
else
- field_type = make_signed_type (prec);
- SET_TYPE_RM_SIZE (field_type, TYPE_RM_SIZE (type));
+ field_type = type;
field = create_field_decl (get_identifier ("OBJ"), field_type, rec_type,
- NULL_TREE, bitsize_zero_node, 1, 0);
+ NULL_TREE, bitsize_zero_node, c < 0, 0);
finish_record_type (rec_type, field, 1, false);
The same considerations as above apply if the target type is an aggregate
type with reverse storage order and we also proceed similarly. */
- else if (INTEGRAL_TYPE_P (etype)
- && TYPE_RM_SIZE (etype)
- && (tree_int_cst_compare (TYPE_RM_SIZE (etype),
- TYPE_SIZE (etype)) < 0
- || (AGGREGATE_TYPE_P (type)
- && TYPE_REVERSE_STORAGE_ORDER (type))))
+ else if ((INTEGRAL_TYPE_P (etype)
+ && TYPE_RM_SIZE (etype)
+ && ((c = tree_int_cst_compare (TYPE_RM_SIZE (etype),
+ TYPE_SIZE (etype))) < 0
+ || reverse))
+ || (SCALAR_FLOAT_TYPE_P (etype) && reverse))
{
tree rec_type = make_node (RECORD_TYPE);
- unsigned HOST_WIDE_INT prec = TREE_INT_CST_LOW (TYPE_RM_SIZE (etype));
vec<constructor_elt, va_gc> *v;
vec_alloc (v, 1);
tree field_type, field;
- if (AGGREGATE_TYPE_P (type))
- TYPE_REVERSE_STORAGE_ORDER (rec_type)
- = TYPE_REVERSE_STORAGE_ORDER (type);
+ TYPE_REVERSE_STORAGE_ORDER (rec_type) = reverse;
- if (type_unsigned_for_rm (etype))
- field_type = make_unsigned_type (prec);
+ if (c < 0)
+ {
+ const unsigned HOST_WIDE_INT prec
+ = TREE_INT_CST_LOW (TYPE_RM_SIZE (etype));
+ if (type_unsigned_for_rm (etype))
+ field_type = make_unsigned_type (prec);
+ else
+ field_type = make_signed_type (prec);
+ SET_TYPE_RM_SIZE (field_type, TYPE_RM_SIZE (etype));
+ }
else
- field_type = make_signed_type (prec);
- SET_TYPE_RM_SIZE (field_type, TYPE_RM_SIZE (etype));
+ field_type = etype;
field = create_field_decl (get_identifier ("OBJ"), field_type, rec_type,
- NULL_TREE, bitsize_zero_node, 1, 0);
+ NULL_TREE, bitsize_zero_node, c < 0, 0);
finish_record_type (rec_type, field, 1, false);
signed and have the same precision. */
tree type_rm_size;
if (!notrunc_p
+ && !biased
&& INTEGRAL_TYPE_P (type)
- && !(code == INTEGER_TYPE && TYPE_BIASED_REPRESENTATION_P (type))
&& (type_rm_size = TYPE_RM_SIZE (type))
&& tree_int_cst_compare (type_rm_size, TYPE_SIZE (type)) < 0
&& !(INTEGRAL_TYPE_P (etype)