From 883c9d4d1237863941b95b3e7b8dba71fb49a78e Mon Sep 17 00:00:00 2001 From: Victor Leikehman Date: Mon, 9 Aug 2004 14:34:39 +0000 Subject: matmul.m4, [...]: Allocate space if return value has NULL in its data field. 2004-09-09 Victor Leikehman * m4/matmul.m4, m4/matmull.m4, intrinsics/eoshift0.c, intrinsics/eoshift2.c, intrinsics/transpose_generic.c: Allocate space if return value has NULL in its data field. * generated/*.c: Regenerate. From-SVN: r85717 --- libgfortran/m4/matmul.m4 | 32 +++++++++++++++++++++++++++++++- libgfortran/m4/matmull.m4 | 30 ++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) (limited to 'libgfortran/m4') diff --git a/libgfortran/m4/matmul.m4 b/libgfortran/m4/matmul.m4 index 26b241d..7a54b05 100644 --- a/libgfortran/m4/matmul.m4 +++ b/libgfortran/m4/matmul.m4 @@ -2,7 +2,7 @@ Copyright 2002 Free Software Foundation, Inc. Contributed by Paul Brook -This file is part of the GNU Fortran 95 runtime library (libgfor). +This file is part of the GNU Fortran 95 runtime library (libgfortran). Libgfortran is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -52,6 +52,36 @@ void assert (GFC_DESCRIPTOR_RANK (a) == 2 || GFC_DESCRIPTOR_RANK (b) == 2); + + if (retarray->data == NULL) + { + if (GFC_DESCRIPTOR_RANK (a) == 1) + { + retarray->dim[0].lbound = 0; + retarray->dim[0].ubound = b->dim[1].ubound - b->dim[1].lbound; + retarray->dim[0].stride = 1; + } + else if (GFC_DESCRIPTOR_RANK (b) == 1) + { + retarray->dim[0].lbound = 0; + retarray->dim[0].ubound = a->dim[0].ubound - a->dim[0].lbound; + retarray->dim[0].stride = 1; + } + else + { + retarray->dim[0].lbound = 0; + retarray->dim[0].ubound = a->dim[0].ubound - a->dim[0].lbound; + retarray->dim[0].stride = 1; + + retarray->dim[1].lbound = 0; + retarray->dim[1].ubound = b->dim[1].ubound - b->dim[1].lbound; + retarray->dim[1].stride = retarray->dim[0].ubound+1; + } + + retarray->data = internal_malloc (sizeof (rtype_name) * size0 (retarray)); + retarray->base = 0; + } + abase = a->data; bbase = b->data; dest = retarray->data; diff --git a/libgfortran/m4/matmull.m4 b/libgfortran/m4/matmull.m4 index 4ee32fb..804127e 100644 --- a/libgfortran/m4/matmull.m4 +++ b/libgfortran/m4/matmull.m4 @@ -51,6 +51,36 @@ void assert (GFC_DESCRIPTOR_RANK (a) == 2 || GFC_DESCRIPTOR_RANK (b) == 2); + + if (retarray->data == NULL) + { + if (GFC_DESCRIPTOR_RANK (a) == 1) + { + retarray->dim[0].lbound = 0; + retarray->dim[0].ubound = b->dim[1].ubound - b->dim[1].lbound; + retarray->dim[0].stride = 1; + } + else if (GFC_DESCRIPTOR_RANK (b) == 1) + { + retarray->dim[0].lbound = 0; + retarray->dim[0].ubound = a->dim[0].ubound - a->dim[0].lbound; + retarray->dim[0].stride = 1; + } + else + { + retarray->dim[0].lbound = 0; + retarray->dim[0].ubound = a->dim[0].ubound - a->dim[0].lbound; + retarray->dim[0].stride = 1; + + retarray->dim[1].lbound = 0; + retarray->dim[1].ubound = b->dim[1].ubound - b->dim[1].lbound; + retarray->dim[1].stride = retarray->dim[0].ubound+1; + } + + retarray->data = internal_malloc (sizeof (rtype_name) * size0 (retarray)); + retarray->base = 0; + } + abase = a->data; if (GFC_DESCRIPTOR_SIZE (a) != 4) { -- cgit v1.1