+2018-02-04 Paul Thomas <pault@gcc.gnu.org>
+
+ 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 <pault@gcc.gnu.org>
PR fortran/84141
/* 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);
+2018-02-04 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/84115
+ * gfortran.dg/associate_34.f90: New test.
+ * gfortran.dg/associate_35.f90: New test.
+
2018-02-03 Paul Thomas <pault@gcc.gnu.org>
PR fortran/84141
--- /dev/null
+! { dg-do run }
+!
+! Test the fix for PR84115.
+!
+! Contributed by G Steinmetz <gscfq@t-online.de>
+!
+ 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
--- /dev/null
+! { dg-do compile }
+!
+! Test the fix for PR84115 comment #1 (except for s1(x)!).
+!
+! Contributed by G Steinmetz <gscfq@t-online.de>
+!
+ 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