From 5fcc57ced0054855920854726836938ace1573c9 Mon Sep 17 00:00:00 2001 From: pbrook Date: Wed, 4 Aug 2004 14:30:46 +0000 Subject: * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@85558 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgfortran/m4/ifunction.m4 | 17 +++++++++++++++++ libgfortran/m4/transpose.m4 | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) (limited to 'libgfortran/m4') 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) -- cgit v1.2.1