From d48fc34a45248f83f3d00b1ba7d8ec46854702c8 Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Mon, 19 Feb 2018 18:21:45 +0000 Subject: [PATCH] re PR fortran/35339 (Improve translation of implied do loop in transfer) 2018-02-19 Thomas Koenig PR fortran/35339 * frontend-passes.c (traverse_io_block): Remove workaround for PR 80945. 2018-02-19 Thomas Koenig PR fortran/35339 * gfortran.dg/implied_do_io_4.f90: New test. From-SVN: r257814 --- gcc/fortran/ChangeLog | 6 +++++ gcc/fortran/frontend-passes.c | 7 ------ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/implied_do_io_4.f90 | 22 +++++++++++++++++++ 4 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/implied_do_io_4.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index e75361b6360..32646ebf8f7 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-02-19 Thomas Koenig + + PR fortran/35339 + * frontend-passes.c (traverse_io_block): Remove workaround for + PR 80945. + 2018-02-19 Andre Vehreschild * gfortran.texi: Document additional src/dst_type. Fix some typos. diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index d07d142faa4..1ffd27d686a 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -1162,14 +1162,7 @@ traverse_io_block (gfc_code *code, bool *has_reached, gfc_code *prev) gcc_assert (curr->op == EXEC_TRANSFER); - /* FIXME: Workaround for PR 80945 - array slices with deferred character - lenghts do not work. Remove this section when the PR is fixed. */ e = curr->expr1; - if (e->expr_type == EXPR_VARIABLE && e->ts.type == BT_CHARACTER - && e->ts.deferred) - return false; - /* End of section to be removed. */ - ref = e->ref; if (!ref || ref->type != REF_ARRAY || ref->u.ar.codimen != 0 || ref->next) return false; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ef615a4eeca..7f989013c90 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-02-19 Thomas Koenig + + PR fortran/35339 + * gfortran.dg/implied_do_io_4.f90: New test. + 2018-02-19 Andre Vehreschild * gfortran.dg/coarray_alloc_comp_6.f08: New test. diff --git a/gcc/testsuite/gfortran.dg/implied_do_io_4.f90 b/gcc/testsuite/gfortran.dg/implied_do_io_4.f90 new file mode 100644 index 00000000000..4b484d7d500 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/implied_do_io_4.f90 @@ -0,0 +1,22 @@ +! { dg-do run } +! { dg-additional-options "-ffrontend-optimize -fdump-tree-original" } +! PR fortran/35339 - make sure that I/O of an implied DO loop +! of allocatable character arrays a) works and b) is converted +! to a transfer_array +program main + implicit none + integer:: i + integer, parameter:: N = 10 + character(len=:), dimension(:),allocatable:: ca + allocate(character(len=N):: ca(3)) + open(unit=10,status="scratch") + ca(1) = "foo" + ca(2) = "bar" + ca(3) = "xyzzy" + write (10, '(3A10)') (ca(i),i=1,3) + rewind (10) + ca(:) = '' + read (10, '(3A10)') (ca(i),i=1,3) + if (ca(1) /= 'foo' .or. ca(2) /= 'bar' .or. ca(3) /= 'xyzzy') call abort +end program +! { dg-final { scan-tree-dump-times "_gfortran_transfer_array" 2 "original" } } -- 2.30.2