OSDN Git Service

2009-06-06 Daniel Franke <franke.daniel@gmail.com>
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 6 Jun 2009 21:09:57 +0000 (21:09 +0000)
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 6 Jun 2009 21:09:57 +0000 (21:09 +0000)
        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/37203
        * reshape_zerosize_2.f90: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148238 138bc75d-0d04-0410-961f-82ee72b054a4

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

index b50949f..711367a 100644 (file)
@@ -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 09cf297..737f299 100644 (file)
@@ -3808,7 +3808,7 @@ gfc_simplify_reshape (gfc_expr *source, gfc_expr *shape_exp,
   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 ca9f04f..6b87e85 100644 (file)
@@ -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.
diff --git a/gcc/testsuite/gfortran.dg/reshape_zerosize_2.f90 b/gcc/testsuite/gfortran.dg/reshape_zerosize_2.f90
new file mode 100644 (file)
index 0000000..cdbee42
--- /dev/null
@@ -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