diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2019-01-09 20:31:07 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2019-01-09 20:31:07 +0000 |
commit | ee0b3cea205eb7e832d7262425ddee8ed34778e5 (patch) | |
tree | ecee54824e8a7db5f4123fb1ac5d96a96d14c708 | |
parent | 33142cf9cf82aa1f1be6b8c77f903818c101b9dd (diff) | |
download | gcc-ee0b3cea205eb7e832d7262425ddee8ed34778e5.tar.gz |
re PR fortran/68426 (Simplification of SPREAD with a derived type element is unimplemented)
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
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/simplify.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/spread_simplify_1.f90 | 16 |
4 files changed, 29 insertions, 1 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f29be83229e..14e402cd57a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -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 diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 90477e5dadc..06b0b87d8eb 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c4fa2549312..6837373cbb4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 00000000000..afc254ac39a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/spread_simplify_1.f90 @@ -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 |