From cfd8c4eb73f1db78f8768a325f241bf5006b3975 Mon Sep 17 00:00:00 2001 From: pault Date: Sun, 4 Feb 2018 13:18:33 +0000 Subject: [PATCH] 2018-02-04 Paul Thomas PR fortran/84115 * trans-decl.c (gfc_get_symbol_decl): Do not finish the decl of 'length' if the symbol charlen backend_decl is an indirect ref. 2018-02-04 Paul Thomas PR fortran/84115 * gfortran.dg/associate_34.f90: New test. * gfortran.dg/associate_35.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@257363 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 6 +++++ gcc/fortran/trans-decl.c | 3 ++- gcc/testsuite/ChangeLog | 6 +++++ gcc/testsuite/gfortran.dg/associate_34.f90 | 21 ++++++++++++++++++ gcc/testsuite/gfortran.dg/associate_35.f90 | 35 ++++++++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/associate_34.f90 create mode 100644 gcc/testsuite/gfortran.dg/associate_35.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index da86c839859..4095c011ae0 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-02-04 Paul Thomas + + PR fortran/84115 + * trans-decl.c (gfc_get_symbol_decl): Do not finish the decl of + 'length' if the symbol charlen backend_decl is an indirect ref. + 2018-02-03 Paul Thomas PR fortran/84141 diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 9b0b2a14b8d..4fc07b61c68 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -1774,7 +1774,8 @@ gfc_get_symbol_decl (gfc_symbol * sym) /* Associate names can use the hidden string length variable of their associated target. */ if (sym->ts.type == BT_CHARACTER - && TREE_CODE (length) != INTEGER_CST) + && TREE_CODE (length) != INTEGER_CST + && TREE_CODE (sym->ts.u.cl->backend_decl) != INDIRECT_REF) { gfc_finish_var_decl (length, sym); gcc_assert (!sym->value); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1c34494b982..3c93cba9db1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-02-04 Paul Thomas + + PR fortran/84115 + * gfortran.dg/associate_34.f90: New test. + * gfortran.dg/associate_35.f90: New test. + 2018-02-03 Paul Thomas PR fortran/84141 diff --git a/gcc/testsuite/gfortran.dg/associate_34.f90 b/gcc/testsuite/gfortran.dg/associate_34.f90 new file mode 100644 index 00000000000..629c0b43611 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associate_34.f90 @@ -0,0 +1,21 @@ +! { dg-do run } +! +! Test the fix for PR84115. +! +! Contributed by G Steinmetz +! + character(:), allocatable :: chr + allocate (chr, source = "abc") + call s(chr, "abc") + chr = "mary had a little lamb" + call s(chr, "mary had a little lamb") + deallocate (chr) +contains + subroutine s(x, carg) + character(:), allocatable :: x + character(*) :: carg + associate (y => x) + if (y .ne. carg) call abort + end associate + end +end diff --git a/gcc/testsuite/gfortran.dg/associate_35.f90 b/gcc/testsuite/gfortran.dg/associate_35.f90 new file mode 100644 index 00000000000..417ec7c426b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associate_35.f90 @@ -0,0 +1,35 @@ +! { dg-do compile } +! +! Test the fix for PR84115 comment #1 (except for s1(x)!). +! +! Contributed by G Steinmetz +! + character(:), allocatable :: dum + dum = "s1" + call s1 (dum) + dum = "s2" + call s2 (dum) + dum = "s3" + call s3 (dum) +contains + subroutine s1(x) + character(:), allocatable :: x + associate (y => x//x) ! { dg-error "type character and non-constant length" } + print *, y + end associate + end + + subroutine s2(x) + character(:), allocatable :: x + associate (y => [x]) + print *, y + end associate + end + + subroutine s3(x) + character(:), allocatable :: x + associate (y => [x,x]) + print *, y + end associate + end +end -- 2.11.4.GIT