From cc41ec4ebc020fdf032bb981b5990469649a8926 Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Sun, 25 Mar 2007 08:29:10 +0000 Subject: [PATCH] re PR fortran/31196 ([4.1 only] wrong code generated with RESHAPE/TRANSPOSE) 2007-03-25 Thomas Koenig PR libfortran/31196 * intrinsics/reshape_generic.c (reshape_internal): Increment correct variable. 2007-03-25 Thomas Koenig PR libfortran/31196 * gfortran.dg/reshape_transpose_1.f90: New test. From-SVN: r123195 --- gcc/testsuite/ChangeLog | 5 +++++ .../gfortran.dg/reshape_transpose_1.f90 | 18 ++++++++++++++++++ libgfortran/ChangeLog | 6 ++++++ libgfortran/intrinsics/reshape_generic.c | 2 +- 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/reshape_transpose_1.f90 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e8650e49b79..8f3153281cd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-03-25 Thomas Koenig + + PR libfortran/31196 + * gfortran.dg/reshape_transpose_1.f90: New test. + 2007-03-24 Francois-Xavier Coudert PR fortran/30655 diff --git a/gcc/testsuite/gfortran.dg/reshape_transpose_1.f90 b/gcc/testsuite/gfortran.dg/reshape_transpose_1.f90 new file mode 100644 index 00000000000..5ca52640f2e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/reshape_transpose_1.f90 @@ -0,0 +1,18 @@ +! { dg-do run } +! PR 31196 - reshape of transposed derived types generated +! wront results. +program main + implicit none + TYPE datatype + INTEGER :: I + END TYPE datatype + character (len=20) line1, line2 + TYPE(datatype), dimension(2,2) :: data, result + data(1,1)%i = 1 + data(2,1)%i = 2 + data(1,2)%i = 3 + data(2,2)%i = 4 + write (unit=line1, fmt="(4I4)") reshape(transpose(data),shape(data)) + write (unit=line2, fmt="(4I4)") (/ 1, 3, 2, 4 /) + if (line1 /= line2) call abort +END program main diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 1281bbb12ca..b0b4f19aa99 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +2007-03-25 Thomas Koenig + + PR libfortran/31196 + * intrinsics/reshape_generic.c (reshape_internal): Increment + correct variable. + 2007-03-22 Jerry DeLisle PR libgfortran/31052 diff --git a/libgfortran/intrinsics/reshape_generic.c b/libgfortran/intrinsics/reshape_generic.c index c58fab01795..9a20c197201 100644 --- a/libgfortran/intrinsics/reshape_generic.c +++ b/libgfortran/intrinsics/reshape_generic.c @@ -266,7 +266,7 @@ reshape_internal (parray *ret, parray *source, shape_type *shape, else { scount[n]++; - sptr += sstride[n] * size; + src += sstride[n] * size; } } }