diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2010-10-21 12:25:12 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2010-10-21 12:25:12 +0000 |
commit | 3ba7edcfcccc8c37983e89ee9d80287e6e3bb0f4 (patch) | |
tree | 1e94c7cd4fa400c87e7f43094060b274a34ad669 /libgfortran/m4 | |
parent | 837c4b78f697de3a047f6e6dba919c02fd769809 (diff) | |
download | gcc-3ba7edcfcccc8c37983e89ee9d80287e6e3bb0f4.zip gcc-3ba7edcfcccc8c37983e89ee9d80287e6e3bb0f4.tar.gz gcc-3ba7edcfcccc8c37983e89ee9d80287e6e3bb0f4.tar.bz2 |
re PR fortran/46007 (wrong code for SHAPE in a scalarized loop)
2010-10-21 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/46007
* m4/shape.m4 (shape_'rtype_kind`): Use variable for rank.
Allocate return array if unallocated.
* generated/shape_i4.c: Regenerated.
* generated/shape_i8.c: Regenerated.
* generated/shape_i16.c: Regenerated.
2010-10-21 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/46007
* gfortran.dg/shape_5.f90: New test case.
From-SVN: r165770
Diffstat (limited to 'libgfortran/m4')
-rw-r--r-- | libgfortran/m4/shape.m4 | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/libgfortran/m4/shape.m4 b/libgfortran/m4/shape.m4 index eadd3b9..a289b0a 100644 --- a/libgfortran/m4/shape.m4 +++ b/libgfortran/m4/shape.m4 @@ -42,13 +42,23 @@ shape_'rtype_kind` ('rtype` * const restrict ret, int n; index_type stride; index_type extent; + int rank; + + rank = GFC_DESCRIPTOR_RANK (array); + + if (ret->data == NULL) + { + GFC_DIMENSION_SET(ret->dim[0], 0, rank - 1, 1); + ret->offset = 0; + ret->data = internal_malloc_size (sizeof ('rtype_name`) * rank); + } stride = GFC_DESCRIPTOR_STRIDE(ret,0); if (GFC_DESCRIPTOR_EXTENT(ret,0) < 1) return; - for (n = 0; n < GFC_DESCRIPTOR_RANK (array); n++) + for (n = 0; n < rank; n++) { extent = GFC_DESCRIPTOR_EXTENT(array,n); ret->data[n * stride] = extent > 0 ? extent : 0 ; |