re PR fortran/58989 (internal compiler error when using reshape function)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Tue, 5 Nov 2013 20:02:43 +0000 (20:02 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Tue, 5 Nov 2013 20:02:43 +0000 (20:02 +0000)
2013-11-05  Steven G. Kargl <kargl@gcc.gnu.org>

PR fortran/58989
* check.c (gfc_check_reshape): ensure that shape is a constant
expression.

2013-11-05  Steven G. Kargl <kargl@gcc.gnu.org>

PR fortran/58989
* gfortran.dg/reshape_6.f90: New test.

From-SVN: r204419

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

index 16703f64dfbdbe2d1422cd1a5155ed199955f854..47b9383dac48f5943f74e0faf6220c983757447a 100644 (file)
@@ -1,3 +1,9 @@
+2013-11-05  Steven G. Kargl <kargl@gcc.gnu.org>
+
+       PR fortran/58989
+       * check.c (gfc_check_reshape): ensure that shape is a constant
+       expression.
+
 2013-11-05  Tobias Burnus  <burnus@net-b.de>
 
        * lang.opt (fopenmp-simd): New option.
index 758639e27afaeba36c0e1d5f0c28ec912ed666fb..1508c7447241d359cbdd6881ab3e14f1e8990cac 100644 (file)
@@ -3277,7 +3277,7 @@ gfc_check_reshape (gfc_expr *source, gfc_expr *shape,
                 "than %d elements", &shape->where, GFC_MAX_DIMENSIONS);
       return false;
     }
-  else if (shape->expr_type == EXPR_ARRAY)
+  else if (shape->expr_type == EXPR_ARRAY && gfc_is_constant_expr (shape))
     {
       gfc_expr *e;
       int i, extent;
index a348d7e0b28c3e53e37f47efadbce660dfa38494..21455038c9f69793792f1cdb19270d3716fdf933 100644 (file)
@@ -1,3 +1,8 @@
+2013-11-05  Steven G. Kargl <kargl@gcc.gnu.org>
+
+       PR fortran/58989
+       * gfortran.dg/reshape_6.f90: New test.
+
 2013-10-05  Jeff Law  <law@redhat.com>
 
        * gcc.dg/pr38984.c: Add -fno-isolate-erroneous-paths.
diff --git a/gcc/testsuite/gfortran.dg/reshape_6.f90 b/gcc/testsuite/gfortran.dg/reshape_6.f90
new file mode 100644 (file)
index 0000000..149f31e
--- /dev/null
@@ -0,0 +1,19 @@
+! { dg-do compile }
+! PR fortran/58989
+!
+program test
+
+  real(8), dimension(4,4) :: fluxes
+  real(8), dimension(2,2,2,2) :: f
+  integer, dimension(3) :: dmmy 
+  integer, parameter :: indx(4)=(/2,2,2,2/)
+
+  fluxes = 1
+
+  dmmy = (/2,2,2/)
+
+  f = reshape(fluxes,(/dmmy,2/))  ! Caused an ICE
+  f = reshape(fluxes,(/2,2,2,2/)) ! Works as expected
+  f = reshape(fluxes,indx)        ! Works as expected
+
+end program test