re PR fortran/68426 (Simplification of SPREAD with a derived type element is unimplem...
authorThomas Koenig <tkoenig@gcc.gnu.org>
Wed, 9 Jan 2019 20:31:07 +0000 (20:31 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Wed, 9 Jan 2019 20:31:07 +0000 (20:31 +0000)
2019-01-09  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/68426
* simplify.c (gfc_simplify_spread): Also simplify if the
type of source is an EXPR_STRUCTURE.

2019-01-09  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/68426
* gfortran.dg/spread_simplify_1.f90: New test.

From-SVN: r267781

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

index f29be83229e1a6a54b51a73822157ca1f1a8a656..14e402cd57af2ec2f43794d88f5e78ddfb0be5b5 100644 (file)
@@ -1,3 +1,9 @@
+2019-01-09  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/68426
+       * simplify.c (gfc_simplify_spread): Also simplify if the
+       type of source is an EXPR_STRUCTURE.
+
 2019-01-08  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/88047
index 90477e5dadc7b87ef745653c14f977005327e9f0..06b0b87d8ebef39010c88603dd0ea8b68706d0c3 100644 (file)
@@ -7572,7 +7572,8 @@ gfc_simplify_spread (gfc_expr *source, gfc_expr *dim_expr, gfc_expr *ncopies_exp
        return NULL;
     }
 
-  if (source->expr_type == EXPR_CONSTANT)
+  if (source->expr_type == EXPR_CONSTANT
+      || source->expr_type == EXPR_STRUCTURE)
     {
       gcc_assert (dim == 0);
 
index c4fa25493122631ffb7bd480aa2ed93fcc968cb5..6837373cbb486d6ada5b46c986360dc1d9d86c54 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-09  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/68426
+       * gfortran.dg/spread_simplify_1.f90: New test.
+
 2019-01-09  Uroš Bizjak  <ubizjak@gmail.com>
 
        * lib/target-supports.exp
diff --git a/gcc/testsuite/gfortran.dg/spread_simplify_1.f90 b/gcc/testsuite/gfortran.dg/spread_simplify_1.f90
new file mode 100644 (file)
index 0000000..afc254a
--- /dev/null
@@ -0,0 +1,16 @@
+! { dg-do  run  }
+! PR 68426 - simplification used to fail.
+  module m
+    implicit none
+    type t
+      integer :: i
+    end type t
+    type(t), dimension(2), parameter :: a1  = (/ t(1), t(2) /)
+    type(t), dimension(1), parameter :: c = spread ( a1(1), 1, 1 )
+  end module m
+
+
+program main
+  use m
+  if (c(1)%i /= 1) stop 1
+end program main