This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

[Committed] PR fortran/68566


I've committed the following patch.

2016-07-30  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/68566
	* check.c (gfc_check_reshape): Check for constant expression.

2016-07-30  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/68566
	* gfortran.dg/pr68566.f90: new test.

Index: gcc/fortran/check.c
===================================================================
--- gcc/fortran/check.c	(revision 238905)
+++ gcc/fortran/check.c	(working copy)
@@ -3827,7 +3827,7 @@ gfc_check_reshape (gfc_expr *source, gfc
       if (!type_check (order, 3, BT_INTEGER))
 	return false;
 
-      if (order->expr_type == EXPR_ARRAY)
+      if (order->expr_type == EXPR_ARRAY && gfc_is_constant_expr (order))
 	{
 	  int i, order_size, dim, perm[GFC_MAX_DIMENSIONS];
 	  gfc_expr *e;
Index: gcc/testsuite/gfortran.dg/pr68566.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr68566.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr68566.f90	(working copy)
@@ -0,0 +1,12 @@
+program p
+   character(len=20) s1, s2
+   integer, allocatable :: n(:)
+   n = [2,1]
+   s1 = '1 5 2 6 3 0 4 0'
+   write(s2,'(8(I0,1x))') reshape ([1,2,3,4,5,6], [2,4], [0,0], [2,1])
+   if (trim(s1) /= trim(s2)) call abort
+   write(s2,'(8(I0,1x))') reshape ([1,2,3,4,5,6], [2,4], [0,0], n)
+   if (trim(s1) /= trim(s2)) call abort
+   write(s2,'(8(I0,1x))') reshape ([1,2,3,4,5,6], [2,4], [0,0], [n])
+   if (trim(s1) /= trim(s2)) call abort
+end
-- 
Steve


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