diff options
Diffstat (limited to 'libgfortran/m4')
-rw-r--r-- | libgfortran/m4/cshift1.m4 | 8 | ||||
-rw-r--r-- | libgfortran/m4/eoshift1.m4 | 5 | ||||
-rw-r--r-- | libgfortran/m4/eoshift3.m4 | 5 |
3 files changed, 17 insertions, 1 deletions
diff --git a/libgfortran/m4/cshift1.m4 b/libgfortran/m4/cshift1.m4 index 28fae596bd4..861debeed2c 100644 --- a/libgfortran/m4/cshift1.m4 +++ b/libgfortran/m4/cshift1.m4 @@ -68,6 +68,7 @@ cshift1 (gfc_array_char * const restrict ret, index_type n; int which; 'atype_name` sh; + index_type arraysize; if (pwhich) which = *pwhich - 1; @@ -77,11 +78,13 @@ cshift1 (gfc_array_char * const restrict ret, if (which < 0 || (which + 1) > GFC_DESCRIPTOR_RANK (array)) runtime_error ("Argument ''`DIM''` is out of range in call to ''`CSHIFT''`"); + arraysize = size0 ((array_t *)array); + if (ret->data == NULL) { 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++) @@ -96,6 +99,9 @@ cshift1 (gfc_array_char * const restrict ret, } } + if (arraysize == 0) + return; + extent[0] = 1; count[0] = 0; n = 0; diff --git a/libgfortran/m4/eoshift1.m4 b/libgfortran/m4/eoshift1.m4 index 8ce24eff0f5..01ca57ec68d 100644 --- a/libgfortran/m4/eoshift1.m4 +++ b/libgfortran/m4/eoshift1.m4 @@ -103,6 +103,11 @@ eoshift1 (gfc_array_char * const restrict ret, ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride; } } + else + { + if (size0 ((array_t *) ret) == 0) + return; + } n = 0; for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++) diff --git a/libgfortran/m4/eoshift3.m4 b/libgfortran/m4/eoshift3.m4 index 081ff927277..6a6929ca0c7 100644 --- a/libgfortran/m4/eoshift3.m4 +++ b/libgfortran/m4/eoshift3.m4 @@ -104,6 +104,11 @@ eoshift3 (gfc_array_char * const restrict ret, ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride; } } + else + { + if (size0 ((array_t *) ret) == 0) + return; + } extent[0] = 1; |