From: Paul Thomas Date: Fri, 8 Jan 2021 10:15:22 +0000 (+0000) Subject: Fortran: Allow pointer deferred length associate selectors. [PR93794] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=21c1a30fc73105af50c5e717cb99dc3becabf8fa;p=gcc.git Fortran: Allow pointer deferred length associate selectors. [PR93794] 2021-01-05 Paul Thomas gcc/fortran PR fortran/93794 * trans-expr.c (gfc_conv_component_ref): Remove the condition that deferred character length components only be allocatable. gcc/testsuite/ PR fortran/93794 * gfortran.dg/deferred_character_35.f90 : New test. --- diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 1002448a5ff..7150e48bc93 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -2670,7 +2670,7 @@ gfc_conv_component_ref (gfc_se * se, gfc_ref * ref) /* Allocatable deferred char arrays are to be handled by the gfc_deferred_ strlen () conditional below. */ if (c->ts.type == BT_CHARACTER && !c->attr.proc_pointer - && !(c->attr.allocatable && c->ts.deferred) + && !c->ts.deferred && !c->attr.pdt_string) { tmp = c->ts.u.cl->backend_decl; diff --git a/gcc/testsuite/gfortran.dg/deferred_character_35.f90 b/gcc/testsuite/gfortran.dg/deferred_character_35.f90 new file mode 100644 index 00000000000..c28f52f79ff --- /dev/null +++ b/gcc/testsuite/gfortran.dg/deferred_character_35.f90 @@ -0,0 +1,18 @@ +! { dg-do compile } +! +! Test the fix for PR93794, where the ASSOCIATE statement ICED on the +! deferred character length, pointer component. +! +! Contributed by Gerhard Steinmetz +! +program p + type t + character(:), pointer :: a + end type + type(t) :: z + character(4), target :: c = 'abcd' + z%a => c + associate (y => z%a) + print *, y + end associate +end