From 6c167c45b1059150631362a647864ee0ca900a91 Mon Sep 17 00:00:00 2001 From: Victor Leikehman Date: Wed, 4 Aug 2004 14:30:46 +0000 Subject: [PATCH] * libgfortran.h (array_t, size0) New declarations. * m4/ifunction.m4, m4/transpose.m4, intrinsics/cshift0.c: Allocate space if return value descriptor has NULL in its data field, and initialize bounds and stride. * intrinsics/size.c (array_t, size0): Declarations moved to libgfortran.h. * generated/*.c: Regenerate. From-SVN: r85558 --- libgfortran/ChangeLog | 10 ++++++++++ libgfortran/generated/all_l4.c | 17 +++++++++++++++++ libgfortran/generated/all_l8.c | 17 +++++++++++++++++ libgfortran/generated/any_l4.c | 17 +++++++++++++++++ libgfortran/generated/any_l8.c | 17 +++++++++++++++++ libgfortran/generated/count_4_l4.c | 17 +++++++++++++++++ libgfortran/generated/count_4_l8.c | 17 +++++++++++++++++ libgfortran/generated/count_8_l4.c | 17 +++++++++++++++++ libgfortran/generated/count_8_l8.c | 17 +++++++++++++++++ libgfortran/generated/maxloc1_4_i4.c | 17 +++++++++++++++++ libgfortran/generated/maxloc1_4_i8.c | 17 +++++++++++++++++ libgfortran/generated/maxloc1_4_r4.c | 17 +++++++++++++++++ libgfortran/generated/maxloc1_4_r8.c | 17 +++++++++++++++++ libgfortran/generated/maxloc1_8_i4.c | 17 +++++++++++++++++ libgfortran/generated/maxloc1_8_i8.c | 17 +++++++++++++++++ libgfortran/generated/maxloc1_8_r4.c | 17 +++++++++++++++++ libgfortran/generated/maxloc1_8_r8.c | 17 +++++++++++++++++ libgfortran/generated/maxval_i4.c | 17 +++++++++++++++++ libgfortran/generated/maxval_i8.c | 17 +++++++++++++++++ libgfortran/generated/maxval_r4.c | 17 +++++++++++++++++ libgfortran/generated/maxval_r8.c | 17 +++++++++++++++++ libgfortran/generated/minloc1_4_i4.c | 17 +++++++++++++++++ libgfortran/generated/minloc1_4_i8.c | 17 +++++++++++++++++ libgfortran/generated/minloc1_4_r4.c | 17 +++++++++++++++++ libgfortran/generated/minloc1_4_r8.c | 17 +++++++++++++++++ libgfortran/generated/minloc1_8_i4.c | 17 +++++++++++++++++ libgfortran/generated/minloc1_8_i8.c | 17 +++++++++++++++++ libgfortran/generated/minloc1_8_r4.c | 17 +++++++++++++++++ libgfortran/generated/minloc1_8_r8.c | 17 +++++++++++++++++ libgfortran/generated/minval_i4.c | 17 +++++++++++++++++ libgfortran/generated/minval_i8.c | 17 +++++++++++++++++ libgfortran/generated/minval_r4.c | 17 +++++++++++++++++ libgfortran/generated/minval_r8.c | 17 +++++++++++++++++ libgfortran/generated/product_c4.c | 17 +++++++++++++++++ libgfortran/generated/product_c8.c | 17 +++++++++++++++++ libgfortran/generated/product_i4.c | 17 +++++++++++++++++ libgfortran/generated/product_i8.c | 17 +++++++++++++++++ libgfortran/generated/product_r4.c | 17 +++++++++++++++++ libgfortran/generated/product_r8.c | 17 +++++++++++++++++ libgfortran/generated/sum_c4.c | 17 +++++++++++++++++ libgfortran/generated/sum_c8.c | 17 +++++++++++++++++ libgfortran/generated/sum_i4.c | 17 +++++++++++++++++ libgfortran/generated/sum_i8.c | 17 +++++++++++++++++ libgfortran/generated/sum_r4.c | 17 +++++++++++++++++ libgfortran/generated/sum_r8.c | 17 +++++++++++++++++ libgfortran/generated/transpose_i4.c | 15 +++++++++++++++ libgfortran/generated/transpose_i8.c | 15 +++++++++++++++ libgfortran/intrinsics/cshift0.c | 25 ++++++++++++++++++++++--- libgfortran/intrinsics/size.c | 3 --- libgfortran/libgfortran.h | 7 +++++++ libgfortran/m4/ifunction.m4 | 17 +++++++++++++++++ libgfortran/m4/transpose.m4 | 17 +++++++++++++++++ 52 files changed, 851 insertions(+), 6 deletions(-) diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 2593982c487..3aaf82fd6f6 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,13 @@ +2004-08-04 Victor Leikehman + + * libgfortran.h (array_t, size0) New declarations. + * m4/ifunction.m4, m4/transpose.m4, intrinsics/cshift0.c: Allocate + space if return value descriptor has NULL in its data field, + and initialize bounds and stride. + * intrinsics/size.c (array_t, size0): Declarations moved to + libgfortran.h. + * generated/*.c: Regenerate. + 2004-08-03 Roger Sayle PR libgfortran/16137 diff --git a/libgfortran/generated/all_l4.c b/libgfortran/generated/all_l4.c index 3ad6a3d43f9..671684fa57f 100644 --- a/libgfortran/generated/all_l4.c +++ b/libgfortran/generated/all_l4.c @@ -63,6 +63,23 @@ __all_l4 (gfc_array_l4 * retarray, gfc_array_l4 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_LOGICAL_4) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/all_l8.c b/libgfortran/generated/all_l8.c index a407a65011b..3f418ccc45f 100644 --- a/libgfortran/generated/all_l8.c +++ b/libgfortran/generated/all_l8.c @@ -63,6 +63,23 @@ __all_l8 (gfc_array_l8 * retarray, gfc_array_l8 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_LOGICAL_8) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/any_l4.c b/libgfortran/generated/any_l4.c index 0d79ce72e30..64cd6757a48 100644 --- a/libgfortran/generated/any_l4.c +++ b/libgfortran/generated/any_l4.c @@ -63,6 +63,23 @@ __any_l4 (gfc_array_l4 * retarray, gfc_array_l4 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_LOGICAL_4) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/any_l8.c b/libgfortran/generated/any_l8.c index e6ac3f5919d..c9f418dcd07 100644 --- a/libgfortran/generated/any_l8.c +++ b/libgfortran/generated/any_l8.c @@ -63,6 +63,23 @@ __any_l8 (gfc_array_l8 * retarray, gfc_array_l8 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_LOGICAL_8) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/count_4_l4.c b/libgfortran/generated/count_4_l4.c index f3087e45442..626ebf944e7 100644 --- a/libgfortran/generated/count_4_l4.c +++ b/libgfortran/generated/count_4_l4.c @@ -63,6 +63,23 @@ __count_4_l4 (gfc_array_i4 * retarray, gfc_array_l4 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_4) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/count_4_l8.c b/libgfortran/generated/count_4_l8.c index 92c1b2f76a3..2db569aac50 100644 --- a/libgfortran/generated/count_4_l8.c +++ b/libgfortran/generated/count_4_l8.c @@ -63,6 +63,23 @@ __count_4_l8 (gfc_array_i4 * retarray, gfc_array_l8 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_4) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/count_8_l4.c b/libgfortran/generated/count_8_l4.c index 4944eb2cfd3..dadbc96fb4e 100644 --- a/libgfortran/generated/count_8_l4.c +++ b/libgfortran/generated/count_8_l4.c @@ -63,6 +63,23 @@ __count_8_l4 (gfc_array_i8 * retarray, gfc_array_l4 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_8) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/count_8_l8.c b/libgfortran/generated/count_8_l8.c index 7d7f4b5c032..d453e01e45b 100644 --- a/libgfortran/generated/count_8_l8.c +++ b/libgfortran/generated/count_8_l8.c @@ -63,6 +63,23 @@ __count_8_l8 (gfc_array_i8 * retarray, gfc_array_l8 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_8) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/maxloc1_4_i4.c b/libgfortran/generated/maxloc1_4_i4.c index dff8627c974..f2a3718482a 100644 --- a/libgfortran/generated/maxloc1_4_i4.c +++ b/libgfortran/generated/maxloc1_4_i4.c @@ -65,6 +65,23 @@ __maxloc1_4_i4 (gfc_array_i4 * retarray, gfc_array_i4 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_4) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/maxloc1_4_i8.c b/libgfortran/generated/maxloc1_4_i8.c index dbb3cd0a787..25a93bae5e5 100644 --- a/libgfortran/generated/maxloc1_4_i8.c +++ b/libgfortran/generated/maxloc1_4_i8.c @@ -65,6 +65,23 @@ __maxloc1_4_i8 (gfc_array_i4 * retarray, gfc_array_i8 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_4) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/maxloc1_4_r4.c b/libgfortran/generated/maxloc1_4_r4.c index d44c556eea6..5dbf0e6442e 100644 --- a/libgfortran/generated/maxloc1_4_r4.c +++ b/libgfortran/generated/maxloc1_4_r4.c @@ -65,6 +65,23 @@ __maxloc1_4_r4 (gfc_array_i4 * retarray, gfc_array_r4 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_4) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/maxloc1_4_r8.c b/libgfortran/generated/maxloc1_4_r8.c index 4fe00d60f23..90b81865128 100644 --- a/libgfortran/generated/maxloc1_4_r8.c +++ b/libgfortran/generated/maxloc1_4_r8.c @@ -65,6 +65,23 @@ __maxloc1_4_r8 (gfc_array_i4 * retarray, gfc_array_r8 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_4) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/maxloc1_8_i4.c b/libgfortran/generated/maxloc1_8_i4.c index 794c6f6936f..a705e79d794 100644 --- a/libgfortran/generated/maxloc1_8_i4.c +++ b/libgfortran/generated/maxloc1_8_i4.c @@ -65,6 +65,23 @@ __maxloc1_8_i4 (gfc_array_i8 * retarray, gfc_array_i4 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_8) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/maxloc1_8_i8.c b/libgfortran/generated/maxloc1_8_i8.c index f755afb90d9..5edd7d480a5 100644 --- a/libgfortran/generated/maxloc1_8_i8.c +++ b/libgfortran/generated/maxloc1_8_i8.c @@ -65,6 +65,23 @@ __maxloc1_8_i8 (gfc_array_i8 * retarray, gfc_array_i8 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_8) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/maxloc1_8_r4.c b/libgfortran/generated/maxloc1_8_r4.c index 8e26f1c3549..5476736e205 100644 --- a/libgfortran/generated/maxloc1_8_r4.c +++ b/libgfortran/generated/maxloc1_8_r4.c @@ -65,6 +65,23 @@ __maxloc1_8_r4 (gfc_array_i8 * retarray, gfc_array_r4 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_8) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/maxloc1_8_r8.c b/libgfortran/generated/maxloc1_8_r8.c index 5955f198979..0fba535c975 100644 --- a/libgfortran/generated/maxloc1_8_r8.c +++ b/libgfortran/generated/maxloc1_8_r8.c @@ -65,6 +65,23 @@ __maxloc1_8_r8 (gfc_array_i8 * retarray, gfc_array_r8 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_8) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/maxval_i4.c b/libgfortran/generated/maxval_i4.c index d130156b57d..90fc202331d 100644 --- a/libgfortran/generated/maxval_i4.c +++ b/libgfortran/generated/maxval_i4.c @@ -64,6 +64,23 @@ __maxval_i4 (gfc_array_i4 * retarray, gfc_array_i4 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_4) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/maxval_i8.c b/libgfortran/generated/maxval_i8.c index 3645346286a..9746503707b 100644 --- a/libgfortran/generated/maxval_i8.c +++ b/libgfortran/generated/maxval_i8.c @@ -64,6 +64,23 @@ __maxval_i8 (gfc_array_i8 * retarray, gfc_array_i8 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_8) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/maxval_r4.c b/libgfortran/generated/maxval_r4.c index 6e82ad68dfb..de999ab390e 100644 --- a/libgfortran/generated/maxval_r4.c +++ b/libgfortran/generated/maxval_r4.c @@ -64,6 +64,23 @@ __maxval_r4 (gfc_array_r4 * retarray, gfc_array_r4 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_REAL_4) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/maxval_r8.c b/libgfortran/generated/maxval_r8.c index 34359d61984..fa357b443fa 100644 --- a/libgfortran/generated/maxval_r8.c +++ b/libgfortran/generated/maxval_r8.c @@ -64,6 +64,23 @@ __maxval_r8 (gfc_array_r8 * retarray, gfc_array_r8 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_REAL_8) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/minloc1_4_i4.c b/libgfortran/generated/minloc1_4_i4.c index 7cd7dd1a2dd..be9ae2e452d 100644 --- a/libgfortran/generated/minloc1_4_i4.c +++ b/libgfortran/generated/minloc1_4_i4.c @@ -65,6 +65,23 @@ __minloc1_4_i4 (gfc_array_i4 * retarray, gfc_array_i4 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_4) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/minloc1_4_i8.c b/libgfortran/generated/minloc1_4_i8.c index bbbb02fc7f3..2f17baacbf0 100644 --- a/libgfortran/generated/minloc1_4_i8.c +++ b/libgfortran/generated/minloc1_4_i8.c @@ -65,6 +65,23 @@ __minloc1_4_i8 (gfc_array_i4 * retarray, gfc_array_i8 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_4) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/minloc1_4_r4.c b/libgfortran/generated/minloc1_4_r4.c index e59427bd184..7f3449f716b 100644 --- a/libgfortran/generated/minloc1_4_r4.c +++ b/libgfortran/generated/minloc1_4_r4.c @@ -65,6 +65,23 @@ __minloc1_4_r4 (gfc_array_i4 * retarray, gfc_array_r4 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_4) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/minloc1_4_r8.c b/libgfortran/generated/minloc1_4_r8.c index 77b3fabeb7c..226d7271c06 100644 --- a/libgfortran/generated/minloc1_4_r8.c +++ b/libgfortran/generated/minloc1_4_r8.c @@ -65,6 +65,23 @@ __minloc1_4_r8 (gfc_array_i4 * retarray, gfc_array_r8 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_4) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/minloc1_8_i4.c b/libgfortran/generated/minloc1_8_i4.c index 1e1c0e1593f..1d1c3d406aa 100644 --- a/libgfortran/generated/minloc1_8_i4.c +++ b/libgfortran/generated/minloc1_8_i4.c @@ -65,6 +65,23 @@ __minloc1_8_i4 (gfc_array_i8 * retarray, gfc_array_i4 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_8) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/minloc1_8_i8.c b/libgfortran/generated/minloc1_8_i8.c index 6b7d5267deb..f7b46c17cf7 100644 --- a/libgfortran/generated/minloc1_8_i8.c +++ b/libgfortran/generated/minloc1_8_i8.c @@ -65,6 +65,23 @@ __minloc1_8_i8 (gfc_array_i8 * retarray, gfc_array_i8 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_8) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/minloc1_8_r4.c b/libgfortran/generated/minloc1_8_r4.c index 4d088a160f3..d71d05621ea 100644 --- a/libgfortran/generated/minloc1_8_r4.c +++ b/libgfortran/generated/minloc1_8_r4.c @@ -65,6 +65,23 @@ __minloc1_8_r4 (gfc_array_i8 * retarray, gfc_array_r4 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_8) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/minloc1_8_r8.c b/libgfortran/generated/minloc1_8_r8.c index 66a1c120749..7de9a2e0377 100644 --- a/libgfortran/generated/minloc1_8_r8.c +++ b/libgfortran/generated/minloc1_8_r8.c @@ -65,6 +65,23 @@ __minloc1_8_r8 (gfc_array_i8 * retarray, gfc_array_r8 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_8) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/minval_i4.c b/libgfortran/generated/minval_i4.c index 70f9b981dfe..e2e68237601 100644 --- a/libgfortran/generated/minval_i4.c +++ b/libgfortran/generated/minval_i4.c @@ -64,6 +64,23 @@ __minval_i4 (gfc_array_i4 * retarray, gfc_array_i4 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_4) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/minval_i8.c b/libgfortran/generated/minval_i8.c index bfac7bad5ff..4b7bac6b532 100644 --- a/libgfortran/generated/minval_i8.c +++ b/libgfortran/generated/minval_i8.c @@ -64,6 +64,23 @@ __minval_i8 (gfc_array_i8 * retarray, gfc_array_i8 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_8) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/minval_r4.c b/libgfortran/generated/minval_r4.c index 0dd156b5816..8d4e49055be 100644 --- a/libgfortran/generated/minval_r4.c +++ b/libgfortran/generated/minval_r4.c @@ -64,6 +64,23 @@ __minval_r4 (gfc_array_r4 * retarray, gfc_array_r4 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_REAL_4) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/minval_r8.c b/libgfortran/generated/minval_r8.c index 99cd6873d27..8300f749681 100644 --- a/libgfortran/generated/minval_r8.c +++ b/libgfortran/generated/minval_r8.c @@ -64,6 +64,23 @@ __minval_r8 (gfc_array_r8 * retarray, gfc_array_r8 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_REAL_8) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/product_c4.c b/libgfortran/generated/product_c4.c index e4df38bebf2..c69295123ef 100644 --- a/libgfortran/generated/product_c4.c +++ b/libgfortran/generated/product_c4.c @@ -63,6 +63,23 @@ __product_c4 (gfc_array_c4 * retarray, gfc_array_c4 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_COMPLEX_4) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/product_c8.c b/libgfortran/generated/product_c8.c index 427043751ae..68a678586bb 100644 --- a/libgfortran/generated/product_c8.c +++ b/libgfortran/generated/product_c8.c @@ -63,6 +63,23 @@ __product_c8 (gfc_array_c8 * retarray, gfc_array_c8 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_COMPLEX_8) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/product_i4.c b/libgfortran/generated/product_i4.c index b8fb8793143..889d4c1bd67 100644 --- a/libgfortran/generated/product_i4.c +++ b/libgfortran/generated/product_i4.c @@ -63,6 +63,23 @@ __product_i4 (gfc_array_i4 * retarray, gfc_array_i4 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_4) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/product_i8.c b/libgfortran/generated/product_i8.c index 210e61792c7..74e0459c6b9 100644 --- a/libgfortran/generated/product_i8.c +++ b/libgfortran/generated/product_i8.c @@ -63,6 +63,23 @@ __product_i8 (gfc_array_i8 * retarray, gfc_array_i8 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_8) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/product_r4.c b/libgfortran/generated/product_r4.c index c615bbd33da..e18139d6b1b 100644 --- a/libgfortran/generated/product_r4.c +++ b/libgfortran/generated/product_r4.c @@ -63,6 +63,23 @@ __product_r4 (gfc_array_r4 * retarray, gfc_array_r4 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_REAL_4) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/product_r8.c b/libgfortran/generated/product_r8.c index 4d12052be86..ce29c1a8ca2 100644 --- a/libgfortran/generated/product_r8.c +++ b/libgfortran/generated/product_r8.c @@ -63,6 +63,23 @@ __product_r8 (gfc_array_r8 * retarray, gfc_array_r8 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_REAL_8) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/sum_c4.c b/libgfortran/generated/sum_c4.c index 91c4e84bf9b..36e20e2e81c 100644 --- a/libgfortran/generated/sum_c4.c +++ b/libgfortran/generated/sum_c4.c @@ -63,6 +63,23 @@ __sum_c4 (gfc_array_c4 * retarray, gfc_array_c4 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_COMPLEX_4) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/sum_c8.c b/libgfortran/generated/sum_c8.c index 4ab3e5e36d8..971c597341e 100644 --- a/libgfortran/generated/sum_c8.c +++ b/libgfortran/generated/sum_c8.c @@ -63,6 +63,23 @@ __sum_c8 (gfc_array_c8 * retarray, gfc_array_c8 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_COMPLEX_8) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/sum_i4.c b/libgfortran/generated/sum_i4.c index 2d737a1f661..628a07756f4 100644 --- a/libgfortran/generated/sum_i4.c +++ b/libgfortran/generated/sum_i4.c @@ -63,6 +63,23 @@ __sum_i4 (gfc_array_i4 * retarray, gfc_array_i4 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_4) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/sum_i8.c b/libgfortran/generated/sum_i8.c index 42dfd9f38d6..536719dd7e4 100644 --- a/libgfortran/generated/sum_i8.c +++ b/libgfortran/generated/sum_i8.c @@ -63,6 +63,23 @@ __sum_i8 (gfc_array_i8 * retarray, gfc_array_i8 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_INTEGER_8) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/sum_r4.c b/libgfortran/generated/sum_r4.c index 293b30edb43..611a1131739 100644 --- a/libgfortran/generated/sum_r4.c +++ b/libgfortran/generated/sum_r4.c @@ -63,6 +63,23 @@ __sum_r4 (gfc_array_r4 * retarray, gfc_array_r4 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_REAL_4) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/sum_r8.c b/libgfortran/generated/sum_r8.c index 294c7980ff7..bdc93e0e47a 100644 --- a/libgfortran/generated/sum_r8.c +++ b/libgfortran/generated/sum_r8.c @@ -63,6 +63,23 @@ __sum_r8 (gfc_array_r8 * retarray, gfc_array_r8 *array, index_type *pdim) array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (GFC_REAL_8) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/generated/transpose_i4.c b/libgfortran/generated/transpose_i4.c index 184243f21d4..930aad9f07d 100644 --- a/libgfortran/generated/transpose_i4.c +++ b/libgfortran/generated/transpose_i4.c @@ -38,6 +38,21 @@ __transpose_4 (gfc_array_i4 * ret, gfc_array_i4 * source) assert (GFC_DESCRIPTOR_RANK (source) == 2); + if (ret->data == NULL) + { + ret->data = internal_malloc (sizeof (GFC_INTEGER_4) * size0 (source)); + ret->base = 0; + ret->dtype = source->dtype; + + ret->dim[0].lbound = 0; + ret->dim[0].ubound = source->dim[1].ubound - source->dim[1].lbound; + ret->dim[0].stride = 1; + + ret->dim[1].lbound = 0; + ret->dim[1].ubound = source->dim[0].ubound - source->dim[0].lbound; + ret->dim[1].stride = ret->dim[0].ubound+1; + } + if (ret->dim[0].stride == 0) ret->dim[0].stride = 1; if (source->dim[0].stride == 0) diff --git a/libgfortran/generated/transpose_i8.c b/libgfortran/generated/transpose_i8.c index 2dcaa000889..c4554e6c210 100644 --- a/libgfortran/generated/transpose_i8.c +++ b/libgfortran/generated/transpose_i8.c @@ -38,6 +38,21 @@ __transpose_8 (gfc_array_i8 * ret, gfc_array_i8 * source) assert (GFC_DESCRIPTOR_RANK (source) == 2); + if (ret->data == NULL) + { + ret->data = internal_malloc (sizeof (GFC_INTEGER_8) * size0 (source)); + ret->base = 0; + ret->dtype = source->dtype; + + ret->dim[0].lbound = 0; + ret->dim[0].ubound = source->dim[1].ubound - source->dim[1].lbound; + ret->dim[0].stride = 1; + + ret->dim[1].lbound = 0; + ret->dim[1].ubound = source->dim[0].ubound - source->dim[0].lbound; + ret->dim[1].stride = ret->dim[0].ubound+1; + } + if (ret->dim[0].stride == 0) ret->dim[0].stride = 1; if (source->dim[0].stride == 0) diff --git a/libgfortran/intrinsics/cshift0.c b/libgfortran/intrinsics/cshift0.c index 5a2c8caabe4..dd96ddf173c 100644 --- a/libgfortran/intrinsics/cshift0.c +++ b/libgfortran/intrinsics/cshift0.c @@ -29,7 +29,7 @@ Boston, MA 02111-1307, USA. */ sizeof(int) < sizeof (index_type). */ static void -__cshift0 (const gfc_array_char * ret, const gfc_array_char * array, +__cshift0 (gfc_array_char * ret, const gfc_array_char * array, int shift, int which) { /* r.* indicates the return array. */ @@ -69,6 +69,25 @@ __cshift0 (const gfc_array_char * ret, const gfc_array_char * array, soffset = size; len = 0; + if (ret->data == NULL) + { + int i; + + ret->data = internal_malloc (size * size0 ((array_t *)array)); + ret->base = 0; + ret->dtype = array->dtype; + for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++) + { + ret->dim[i].lbound = 0; + ret->dim[i].ubound = array->dim[i].ubound - array->dim[i].lbound; + + if (i == 0) + ret->dim[i].stride = 1; + else + ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride; + } + } + for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++) { if (dim == which) @@ -153,7 +172,7 @@ __cshift0 (const gfc_array_char * ret, const gfc_array_char * array, void -__cshift0_4 (const gfc_array_char * ret, const gfc_array_char * array, +__cshift0_4 (gfc_array_char * ret, const gfc_array_char * array, const GFC_INTEGER_4 * pshift, const GFC_INTEGER_4 * pdim) { __cshift0 (ret, array, *pshift, pdim ? *pdim : 1); @@ -161,7 +180,7 @@ __cshift0_4 (const gfc_array_char * ret, const gfc_array_char * array, void -__cshift0_8 (const gfc_array_char * ret, const gfc_array_char * array, +__cshift0_8 (gfc_array_char * ret, const gfc_array_char * array, const GFC_INTEGER_8 * pshift, const GFC_INTEGER_8 * pdim) { __cshift0 (ret, array, *pshift, pdim ? *pdim : 1); diff --git a/libgfortran/intrinsics/size.c b/libgfortran/intrinsics/size.c index 5664c304988..c4c792d6c75 100644 --- a/libgfortran/intrinsics/size.c +++ b/libgfortran/intrinsics/size.c @@ -21,9 +21,6 @@ Boston, MA 02111-1307, USA. */ #include "libgfortran.h" -typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, void) array_t; - -#define size0 prefix(size0) index_type size0 (const array_t * array) { int n; diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h index c0406aaffed..6cc26492898 100644 --- a/libgfortran/libgfortran.h +++ b/libgfortran/libgfortran.h @@ -417,5 +417,12 @@ GFC_REAL_4 normalize_r4_i4 (GFC_UINTEGER_4, GFC_UINTEGER_4); #define normalize_r8_i8 prefix(normalize_r8_i8) GFC_REAL_8 normalize_r8_i8 (GFC_UINTEGER_8, GFC_UINTEGER_8); +/* size.c */ + +typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, void) array_t; + +#define size0 prefix(size0) +index_type size0 (const array_t * array); + #endif diff --git a/libgfortran/m4/ifunction.m4 b/libgfortran/m4/ifunction.m4 index 74cc1e63cd9..14bd0a63997 100644 --- a/libgfortran/m4/ifunction.m4 +++ b/libgfortran/m4/ifunction.m4 @@ -57,6 +57,23 @@ define(START_ARRAY_FUNCTION, array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; } + if (retarray->data == NULL) + { + for (n = 0; n < rank; n++) + { + retarray->dim[n].lbound = 0; + retarray->dim[n].ubound = extent[n]-1; + if (n == 0) + retarray->dim[n].stride = 1; + else + retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; + } + + retarray->data = internal_malloc (sizeof (rtype_name) * + (retarray->dim[rank-1].stride * extent[rank-1])); + retarray->base = 0; + } + for (n = 0; n < rank; n++) { count[n] = 0; diff --git a/libgfortran/m4/transpose.m4 b/libgfortran/m4/transpose.m4 index fbc49501097..5fd6acfb228 100644 --- a/libgfortran/m4/transpose.m4 +++ b/libgfortran/m4/transpose.m4 @@ -39,6 +39,23 @@ void assert (GFC_DESCRIPTOR_RANK (source) == 2); + if (ret->data == NULL) + { + assert (GFC_DESCRIPTOR_RANK (ret) == 2); + assert (ret->dtype == source->dtype); + + ret->dim[0].lbound = 0; + ret->dim[0].ubound = source->dim[1].ubound - source->dim[1].lbound; + ret->dim[0].stride = 1; + + ret->dim[1].lbound = 0; + ret->dim[1].ubound = source->dim[0].ubound - source->dim[0].lbound; + ret->dim[1].stride = ret->dim[0].ubound+1; + + ret->data = internal_malloc (sizeof (rtype_name) * size0 (ret)); + ret->base = 0; + } + if (ret->dim[0].stride == 0) ret->dim[0].stride = 1; if (source->dim[0].stride == 0) -- 2.30.2