@@ -2026,25 +2026,30 @@ copy_char_to_self(void *src, int src_type, int src_size, int src_kind,
20262026
20272027static void
20282028copy_to_self (gfc_descriptor_t * src , int src_kind ,
2029- gfc_descriptor_t * dest , int dst_kind , size_t size , int * stat )
2029+ gfc_descriptor_t * dst , int dst_kind , size_t elem_size , int * stat )
20302030{
2031+ const int src_size = GFC_DESCRIPTOR_SIZE (src ),
2032+ dst_size = GFC_DESCRIPTOR_SIZE (dst );
2033+ const int src_type = GFC_DESCRIPTOR_TYPE (src ),
2034+ dst_type = GFC_DESCRIPTOR_TYPE (dst );
2035+ const int src_rank = GFC_DESCRIPTOR_RANK (src ),
2036+ dst_rank = GFC_DESCRIPTOR_RANK (dst );
20312037#ifdef GFC_CAF_CHECK
2032- if (GFC_DESCRIPTOR_TYPE (dest ) == BT_CHARACTER
2033- || GFC_DESCRIPTOR_TYPE (src ) == BT_CHARACTER )
2038+ if (dst_type == BT_CHARACTER || src_type == BT_CHARACTER )
20342039 caf_runtime_error ("internal error: copy_to_self() for char types called." );
20352040#endif
20362041 /* The address of dest passed by the compiler points on the right
2037- * memory location. No offset summation is needed. */
2038- if (dst_kind == src_kind )
2039- memmove (dest -> base_addr , src -> base_addr , size * GFC_DESCRIPTOR_SIZE (dest ));
2042+ * memory location. No offset summation is needed. Use the convert with
2043+ * strides when src is a scalar. */
2044+ if (dst_kind == src_kind && dst_size == src_size && dst_type == src_type
2045+ && src_rank == dst_rank )
2046+ memmove (dst -> base_addr , src -> base_addr , elem_size * dst_size );
20402047 else
20412048 /* When the rank is 0 then a scalar is copied to a vector and the stride
20422049 * is zero. */
2043- convert_with_strides (dest -> base_addr , GFC_DESCRIPTOR_TYPE (dest ), dst_kind ,
2044- GFC_DESCRIPTOR_SIZE (dest ), src -> base_addr ,
2045- GFC_DESCRIPTOR_TYPE (src ), src_kind ,
2046- (GFC_DESCRIPTOR_RANK (src ) > 0 )
2047- ? GFC_DESCRIPTOR_SIZE (src ) : 0 , size , stat );
2050+ convert_with_strides (dst -> base_addr , dst_type , dst_kind ,
2051+ dst_size , src -> base_addr , src_type , src_kind ,
2052+ src_rank > 0 ? src_size : 0 , elem_size , stat );
20482053}
20492054
20502055/* token: The token of the array to be written to.
0 commit comments