summaryrefslogtreecommitdiff
path: root/libgfortran/intrinsics
diff options
context:
space:
mode:
authorpbrook <pbrook@138bc75d-0d04-0410-961f-82ee72b054a4>2004-08-04 14:30:46 +0000
committerpbrook <pbrook@138bc75d-0d04-0410-961f-82ee72b054a4>2004-08-04 14:30:46 +0000
commit5fcc57ced0054855920854726836938ace1573c9 (patch)
tree4227da0c8f70c91f8b20b53d9be0ca661b7f838a /libgfortran/intrinsics
parent90b0414cbc5cef048c8460ac715ac933fcc4c16b (diff)
downloadgcc-5fcc57ced0054855920854726836938ace1573c9.tar.gz
* 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
Diffstat (limited to 'libgfortran/intrinsics')
-rw-r--r--libgfortran/intrinsics/cshift0.c25
-rw-r--r--libgfortran/intrinsics/size.c3
2 files changed, 22 insertions, 6 deletions
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;