re PR fortran/15957 (Error in array assignments; 'shape'-related stuff)
authorTobias Schlüter <tobias.schlueter@physik.uni-muenchen.de>
Mon, 20 Sep 2004 17:22:50 +0000 (19:22 +0200)
committerTobias Schlüter <tobi@gcc.gnu.org>
Mon, 20 Sep 2004 17:22:50 +0000 (19:22 +0200)
fortran/
PR fortran/15957
* simplify.c (gfc_simplify_reshape): Set shape of return value
correctly.

testsuite/
PR fortran/15957
* gfortran.dg/pr15957.f90: New test.

From-SVN: r87764

gcc/fortran/ChangeLog
gcc/fortran/simplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr15957.f90 [new file with mode: 0644]

index 9053f3652d18c7d5bc83b80873e49024be94a72d..39f739c444a2e53ff00cad559aa564c90c92443e 100644 (file)
@@ -1,3 +1,9 @@
+2004-09-20  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
+
+       PR fortran/15957
+       * simplify.c (gfc_simplify_reshape): Set shape of return value
+       correctly.
+
 2004-09-17  Jeffrey D. Oldham  <oldham@codesourcery.com>
            Zack Weinberg  <zack@codesourcery.com>
 
index 61ef50bdbcb861b63a8c476a163b10cda84ccd74..a599f894c6d943995c682e32e91c8d7e9ca52a01 100644 (file)
@@ -2822,7 +2822,7 @@ inc:
   e->shape = gfc_get_shape (rank);
 
   for (i = 0; i < rank; i++)
-    mpz_init_set_ui (e->shape[i], shape[order[i]]);
+    mpz_init_set_ui (e->shape[i], shape[i]);
 
   e->ts = head->expr->ts;
   e->rank = rank;
index 3414502a11fcf5cf8b4d06bbe2f29e9e2cd7ce76..fe487a187cf71f29ccf613dd26742daa48df4084 100644 (file)
@@ -1,3 +1,8 @@
+2004-09-20  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
+
+       PR fortran/15957
+       * gfortran.dg/pr15957.f90: New test.
+
 2004-09-20  Dorit Naishlos  <dorit@il.ibm.com>
 
        * gcc.dg/vect/vect-74.c: Avoid floating point precision error
diff --git a/gcc/testsuite/gfortran.dg/pr15957.f90 b/gcc/testsuite/gfortran.dg/pr15957.f90
new file mode 100644 (file)
index 0000000..b143913
--- /dev/null
@@ -0,0 +1,27 @@
+! { dg-do run }
+! PR 15957
+! we used to return the wrong shape when the order parameter was used
+! in reshape.
+!
+INTEGER, parameter :: i(2,3) = reshape ((/1,2,3,4,5,6/), (/2,3/)), &
+     j(2,4) = reshape ((/1,2,3,4,5,6/), (/2,4/), (/0,0/), (/2,1/))
+
+integer :: k(2,3), m(2,4), n(2,3), o(2,4)
+
+k(1,:) = (/ 1, 3, 5 /)
+k(2,:) = (/ 2, 4, 6 /)
+
+m(1,:) = (/ 1, 2, 3, 4 /)
+m(2,:) = (/ 5, 6, 0, 0 /)
+
+! check that reshape does the right thing while constant folding
+if (any(i /= k)) call abort()
+if (any(j /= m)) call abort()
+
+! check that reshape does the right thing at runtime
+n = reshape ((/1,2,3,4,5,6/), (/2,3/))
+if (any(n /= k)) call abort()
+o = reshape ((/1,2,3,4,5,6/), (/2,4/), (/0,0/), (/2,1/))
+if (any(o /= m)) call abort()
+end 
+