This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch,Fortran,committed] PR37203: additional checks for RESHAPE


On Thu, Jun 04, 2009 at 11:57:22PM +0200, Tobias Burnus wrote:
> Merge from Fortran-dev to the trunk.
> Original patch by Daniel Franke:
> http://gcc.gnu.org/ml/fortran/2009-01/msg00049.html

I missed a follow-up commit which fixed a regression,
see: http://gcc.gnu.org/ml/fortran/2009-03/msg00324.html
     http://gcc.gnu.org/viewcvs?view=rev&revision=145373

Build, regtested and committed on x86-64-linux:
Sending        gcc/fortran/ChangeLog
Sending        gcc/fortran/simplify.c
Sending        gcc/testsuite/ChangeLog
Adding         gcc/testsuite/gfortran.dg/reshape_zerosize_2.f90
Transmitting file data ....
Committed revision 148238.

Tobias
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog	(Revision 148237)
+++ gcc/testsuite/ChangeLog	(Revision 148238)
@@ -1,5 +1,10 @@
 2009-06-06  Daniel Franke  <franke.daniel@gmail.com>
 
+	PR fortran/37203
+	* reshape_zerosize_2.f90: New.
+
+2009-06-06  Daniel Franke  <franke.daniel@gmail.com>
+
 	PR fortran/32890
 	* gfortran.dg/pack_assign_1.f90: New.
 	* gfortran.dg/pack_vector_1.f90: New.
Index: gcc/testsuite/gfortran.dg/reshape_zerosize_2.f90
===================================================================
--- gcc/testsuite/gfortran.dg/reshape_zerosize_2.f90	(Revision 0)
+++ gcc/testsuite/gfortran.dg/reshape_zerosize_2.f90	(Revision 148238)
@@ -0,0 +1,11 @@
+! { dg-do "run" }
+
+  ! Simplifier of RESHAPE was broken when reshaping an empty array.
+  INTEGER, PARAMETER :: empty(0,0) = RESHAPE(SHAPE(1), (/0, 0/))
+
+  ! same with surplus padding
+  INTEGER, PARAMETER :: empty_padding(0,0) = RESHAPE(SHAPE(1), (/0, 0/), PAD=( (/ 1, 2 /) ))
+
+  ! same with required padding
+  INTEGER, PARAMETER :: non_empty(2,2) = RESHAPE(SHAPE(1), (/2, 2/), PAD=( (/ 1, 2 /) ))
+END
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog	(Revision 148237)
+++ gcc/fortran/ChangeLog	(Revision 148238)
@@ -1,5 +1,11 @@
 2009-06-06  Daniel Franke  <franke.daniel@gmail.com>
 
+	PR fortran/37203
+	* simplify.c (gfc_simplify_reshape): Fixed reshaping of empty arrays
+	without padding.
+
+2009-06-06  Daniel Franke  <franke.daniel@gmail.com>
+
 	PR fortran/32890
 	* intrinsic.h (gfc_simplify_pack): New prototype.
 	* intrinsic.c (add_functions): Added
Index: gcc/fortran/simplify.c
===================================================================
--- gcc/fortran/simplify.c	(Revision 148237)
+++ gcc/fortran/simplify.c	(Revision 148238)
@@ -3808,7 +3808,7 @@ gfc_simplify_reshape (gfc_expr *source,
   for (i = 0; i < rank; i++)
     x[i] = 0;
 
-  for (;;)
+  while (nsource > 0 || npad > 0)
     {
       /* Figure out which element to extract.  */
       mpz_set_ui (index, 0);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]