diff options
Diffstat (limited to 'libgfortran/m4/eoshift3.m4')
-rw-r--r-- | libgfortran/m4/eoshift3.m4 | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/libgfortran/m4/eoshift3.m4 b/libgfortran/m4/eoshift3.m4 index e6b29599ef0..6fa3bd2f7dc 100644 --- a/libgfortran/m4/eoshift3.m4 +++ b/libgfortran/m4/eoshift3.m4 @@ -67,6 +67,7 @@ eoshift3 (gfc_array_char * const restrict ret, index_type len; index_type n; index_type size; + index_type arraysize; int which; 'atype_name` sh; 'atype_name` delta; @@ -77,6 +78,7 @@ eoshift3 (gfc_array_char * const restrict ret, soffset = 0; roffset = 0; + arraysize = size0 ((array_t *) array); size = GFC_DESCRIPTOR_SIZE(array); if (pwhich) @@ -88,7 +90,7 @@ eoshift3 (gfc_array_char * const restrict ret, { int i; - ret->data = internal_malloc_size (size * size0 ((array_t *)array)); + ret->data = internal_malloc_size (size * arraysize); ret->offset = 0; ret->dtype = array->dtype; for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++) @@ -106,13 +108,26 @@ eoshift3 (gfc_array_char * const restrict ret, GFC_DIMENSION_SET(ret->dim[i], 0, ub, str); } + if (arraysize > 0) + ret->data = internal_malloc_size (size * arraysize); + else + ret->data = internal_malloc_size (1); + } - else + else if (unlikely (compile_options.bounds_check)) + { + bounds_equal_extents ((array_t *) ret, (array_t *) array, + "return value", "EOSHIFT"); + } + + if (unlikely (compile_options.bounds_check)) { - if (size0 ((array_t *) ret) == 0) - return; + bounds_reduced_extents ((array_t *) h, (array_t *) array, which, + "SHIFT argument", "EOSHIFT"); } + if (arraysize == 0) + return; extent[0] = 1; count[0] = 0; |