re PR fortran/51434 (ICE with scalar init of an array parameter, used in DT default...
authorSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 3 Mar 2018 18:20:32 +0000 (18:20 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 3 Mar 2018 18:20:32 +0000 (18:20 +0000)
2018-03-03  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/51434
* simplify.c (gfc_simplify_transfer): Resolve mold.

2018-03-03  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/51434
* gfortran.dg/pr51434.f90: New test.

From-SVN: r258220

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

index 5c99760e4c510194e69ce44142786247e606e1a5..c04a552344c3918605526fb8eec8005fcc7d5bd5 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-03  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/51434
+       * simplify.c (gfc_simplify_transfer): Resolve mold.
+
 2018-03-03  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/80965
index 324f85881c5803347ee7d696801b4037feab2c1a..b130abacc521fc4266b4c3f9812ef57d90989f4b 100644 (file)
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gfortran.h"
 #include "arith.h"
 #include "intrinsic.h"
+#include "match.h"
 #include "target-memory.h"
 #include "constructor.h"
 #include "version.h"   /* For version_string.  */
@@ -7370,10 +7371,12 @@ gfc_simplify_transfer (gfc_expr *source, gfc_expr *mold, gfc_expr *size)
   unsigned char *buffer;
   size_t result_length;
 
+  if (!gfc_is_constant_expr (source) || !gfc_is_constant_expr (size))
+    return NULL;
 
-  if (!gfc_is_constant_expr (source)
-       || (gfc_init_expr_flag && !gfc_is_constant_expr (mold))
-       || !gfc_is_constant_expr (size))
+  if (!gfc_resolve_expr (mold))
+    return NULL;
+  if (gfc_init_expr_flag && !gfc_is_constant_expr (mold))
     return NULL;
 
   if (!gfc_calculate_transfer_sizes (source, mold, size, &source_size,
index ed9c809febdb4e5400efdd2451ac59a100ed6b46..2460b06280cb7b733840b7d2444e75f5482f094c 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-03  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/51434
+       * gfortran.dg/pr51434.f90: New test.
+
 2018-03-03  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/61358
diff --git a/gcc/testsuite/gfortran.dg/pr51434.f90 b/gcc/testsuite/gfortran.dg/pr51434.f90
new file mode 100644 (file)
index 0000000..31679ec
--- /dev/null
@@ -0,0 +1,19 @@
+! { dg-do run }
+! PR fortran/51434
+module foo
+   implicit none
+   integer, parameter :: n = 5
+   character(len=1), parameter :: s(n) = 'a'
+   type :: a
+      integer :: m = n
+      character(len=1):: t(n) = transfer('abcde             ', s)
+   end type a
+end module foo
+
+program bar
+   use foo
+   implicit none
+   type(a) c
+   if (c%m /= n) stop 1
+   if (any(c%t /= ['a', 'b', 'c', 'd', 'e'])) stop 2
+end program bar