aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorThomas Koenig <Thomas.Koenig@online.de>2005-04-22 20:02:44 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2005-04-22 20:02:44 +0000
commitda8f3dcc5b46431cf734324750c9435134c78337 (patch)
treecc0f19f26285884c6cba161ccbe33d495e898bb9 /gcc
parentf00fac9d2ffa5ea91809ef1ec85aae415889429c (diff)
downloadgcc-da8f3dcc5b46431cf734324750c9435134c78337.zip
gcc-da8f3dcc5b46431cf734324750c9435134c78337.tar.gz
gcc-da8f3dcc5b46431cf734324750c9435134c78337.tar.bz2
05-04-22 Thomas Koenig <Thomas.Koenig@online.de>
PR libfortran/20074 PR libfortran/20436 PR libfortran/21108 * gfortran.dg/nested_reshape.f90: new test * gfortran.dg/reshape-alloc.f90: new test * gfortran.dg/reshape.f90: new test 2005-04-22 Thomas Koenig <Thomas.Koenig@online.de> PR libfortran/20074 PR libfortran/20436 PR libfortran/21108 * m4/reshape.m4 (reshape_`'rtype_kind): rs, rex: New variables, to be used in calculation of return array sizes. Populate return array descriptor if ret->data is NULL. Fix condition for early return (it used to test something undefined if order was used). Remove duplicate check wether pad is used. * intrinsics/reshape_generic.c (reshape_generic): Likewise. Fix a few places where the wrong variables were set. * generated/reshape_i4.c: Regenerated. * generated/reshape_i8.c: Regenerated. From-SVN: r98585
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog9
-rw-r--r--gcc/testsuite/gfortran.dg/nested_reshape.f9012
-rw-r--r--gcc/testsuite/gfortran.dg/reshape-alloc.f9032
-rw-r--r--gcc/testsuite/gfortran.dg/reshape.f9033
4 files changed, 86 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 505e057..e878656 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+205-04-22 Thomas Koenig <Thomas.Koenig@online.de>
+
+ PR libfortran/20074
+ PR libfortran/20436
+ PR libfortran/21108
+ * gfortran.dg/nested_reshape.f90: new test
+ * gfortran.dg/reshape-alloc.f90: new test
+ * gfortran.dg/reshape.f90: new test
+
2005-04-22 Mark Mitchell <mark@codesourcery.com>
* gcc.dg/arm-vfp1.c: New test.
diff --git a/gcc/testsuite/gfortran.dg/nested_reshape.f90 b/gcc/testsuite/gfortran.dg/nested_reshape.f90
new file mode 100644
index 0000000..d71e4ec
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/nested_reshape.f90
@@ -0,0 +1,12 @@
+! { dg-do run }
+! PR 20436: This used to give a runtime error.
+program nested_reshape
+ implicit none
+ real :: k(8,2)
+ real :: o(8,2)
+
+ k = reshape((/1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0, &
+ 9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0/), (/8,2/))
+
+ o = reshape(reshape(k, (/2,8/), order=(/2,1/)), (/8,2/))
+end program
diff --git a/gcc/testsuite/gfortran.dg/reshape-alloc.f90 b/gcc/testsuite/gfortran.dg/reshape-alloc.f90
new file mode 100644
index 0000000..c4c7a0e
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/reshape-alloc.f90
@@ -0,0 +1,32 @@
+! { dg-do run }
+! PR 20074: This used to segfault at runtime.
+! Test case contributed by "Alfredo Buttari" <pitagoras@tin.it>
+
+program tryreshape
+
+ integer,allocatable :: vect1(:),resh1(:,:)
+ integer,pointer :: vect(:),resh(:,:)
+ integer :: vect2(2*4), resh2(2,4)
+ integer :: r, s(2)
+
+ r=2; nb=4
+
+ s(:)=(/r,nb/)
+
+ allocate(vect(nb*r),vect1(nb*r))
+ allocate(resh(r,nb),resh1(r,nb))
+
+ vect =1
+ vect1=1
+ vect2=1
+
+ resh2 = reshape(vect2,s)
+ if (resh2(1,1) /= 1.0) call abort
+
+ resh1 = reshape(vect1,s)
+ if (resh1(1,1) /= 1.0) call abort
+
+ resh = reshape(vect,s)
+ if (resh(1,1) /= 1.0) call abort
+
+end program tryreshape
diff --git a/gcc/testsuite/gfortran.dg/reshape.f90 b/gcc/testsuite/gfortran.dg/reshape.f90
new file mode 100644
index 0000000..3dba098
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/reshape.f90
@@ -0,0 +1,33 @@
+! { dg-do run }
+! This tests a few reshape PRs.
+program resh
+ implicit none
+ real, dimension (2,3) :: a,c
+ real, dimension (12) :: b
+ type foo
+ real :: r
+ end type foo
+ type(foo), dimension (2,3) :: ar
+ type(foo), dimension (12) :: br
+
+ character (len=80) line1, line2, line3
+ integer :: i
+
+ ! PR 21108: This used to give undefined results.
+ b = (/(i,i=1,12)/)
+ a = reshape(b(1:12:2),shape(a),order=(/2,1/))
+ c = reshape(b(1:12:2),shape(a),order=(/2,1/))
+ if (any (a /= c)) call abort
+
+ ! Test generic reshape
+ br%r = b
+ ar = reshape(br(1:12:2),shape(a),order=(/2,1/))
+ if (any (ar%r /= a)) call abort
+
+ ! Test callee-allocated memory with a write statement
+ write (line1,'(6F8.3)') reshape(b(1:12:2),shape(a),order=(/2,1/))
+ write (line2,'(6F8.3)') a
+ if (line1 /= line2 ) call abort
+ write (line3,'(6F8.3)') reshape(br(1:12:2),shape(ar),order=(/2,1/))
+ if (line1 /= line3 ) call abort
+end