From dc32bc72bb8ba03e66c87db9472d6067dd52d09b Mon Sep 17 00:00:00 2001 From: Paul Thomas Date: Sat, 19 May 2018 10:49:50 +0000 Subject: re PR fortran/82923 (Automatic allocation of deferred length character using function result) 2018-05-19 Paul Thomas PR fortran/82923 PR fortran/66694 PR fortran/82617 * trans-array.c (gfc_alloc_allocatable_for_assignment): Set the charlen backend_decl of the rhs expr to ss->info->string_length so that the value in the current scope is used. 2018-05-19 Paul Thomas PR fortran/82923 * gfortran.dg/allocate_assumed_charlen_4.f90: New test. Note that the patch fixes PR66694 & PR82617, although the testcases are not explicitly included. From-SVN: r260392 --- gcc/fortran/trans-array.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/fortran/trans-array.c') diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index b68e77d..cf4b23f 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -9698,6 +9698,12 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo *loop, if (expr2 && rss == gfc_ss_terminator) return NULL_TREE; + /* Ensure that the string length from the current scope is used. */ + if (expr2->ts.type == BT_CHARACTER + && expr2->expr_type == EXPR_FUNCTION + && !expr2->value.function.isym) + expr2->ts.u.cl->backend_decl = rss->info->string_length; + gfc_start_block (&fblock); /* Since the lhs is allocatable, this must be a descriptor type. -- cgit v1.1