if (!len || TREE_CODE (len) != INTEGER_CST)
return NULL_TREE;
+ tmp = TYPE_SIZE_UNIT (gfc_get_element_type (type));
len = fold_build2 (MULT_EXPR, gfc_array_index_type, len,
- TYPE_SIZE_UNIT (gfc_get_element_type (type)));
+ fold_convert (gfc_array_index_type, tmp));
/* Convert arguments to the correct types. */
if (!POINTER_TYPE_P (TREE_TYPE (dest)))
{
tree dst, dlen, dtype;
tree src, slen, stype;
+ tree tmp;
dst = gfc_get_symbol_decl (expr1->symtree->n.sym);
src = gfc_get_symbol_decl (expr2->symtree->n.sym);
dlen = GFC_TYPE_ARRAY_SIZE (dtype);
if (!dlen || TREE_CODE (dlen) != INTEGER_CST)
return NULL_TREE;
+ tmp = TYPE_SIZE_UNIT (gfc_get_element_type (dtype));
dlen = fold_build2 (MULT_EXPR, gfc_array_index_type, dlen,
- TYPE_SIZE_UNIT (gfc_get_element_type (dtype)));
+ fold_convert (gfc_array_index_type, tmp));
slen = GFC_TYPE_ARRAY_SIZE (stype);
if (!slen || TREE_CODE (slen) != INTEGER_CST)
return NULL_TREE;
+ tmp = TYPE_SIZE_UNIT (gfc_get_element_type (stype));
slen = fold_build2 (MULT_EXPR, gfc_array_index_type, slen,
- TYPE_SIZE_UNIT (gfc_get_element_type (stype)));
+ fold_convert (gfc_array_index_type, tmp));
/* Sanity check that they are the same. This should always be
the case, as we should already have checked for conformance. */
tree dst, dtype;
tree src, stype;
tree len;
+ tree tmp;
nelem = gfc_constant_array_constructor_p (expr2->value.constructor);
if (nelem == 0)
if (compare_tree_int (len, nelem) != 0)
return NULL_TREE;
+ tmp = TYPE_SIZE_UNIT (gfc_get_element_type (dtype));
len = fold_build2 (MULT_EXPR, gfc_array_index_type, len,
- TYPE_SIZE_UNIT (gfc_get_element_type (dtype)));
+ fold_convert (gfc_array_index_type, tmp));
stype = gfc_typenode_for_spec (&expr2->ts);
src = gfc_build_constant_array_constructor (expr2, stype);