OSDN Git Service

PR fortran/32046
[pf3gnuchains/gcc-fork.git] / gcc / fortran / trans-expr.c
index d5f584c..527a44b 100644 (file)
@@ -3619,8 +3619,9 @@ gfc_trans_zero_assign (gfc_expr * expr)
   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)))
@@ -3673,6 +3674,7 @@ gfc_trans_array_copy (gfc_expr * expr1, gfc_expr * expr2)
 {
   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);
@@ -3691,14 +3693,16 @@ gfc_trans_array_copy (gfc_expr * expr1, gfc_expr * expr2)
   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.  */
@@ -3720,6 +3724,7 @@ gfc_trans_array_constructor_copy (gfc_expr * expr1, gfc_expr * expr2)
   tree dst, dtype;
   tree src, stype;
   tree len;
+  tree tmp;
 
   nelem = gfc_constant_array_constructor_p (expr2->value.constructor);
   if (nelem == 0)
@@ -3741,8 +3746,9 @@ gfc_trans_array_constructor_copy (gfc_expr * expr1, gfc_expr * expr2)
   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);