[gcc r9-9709] Fortran: Allow pointer deferred length associate selectors. [PR93794]

Harald Anlauf anlauf@gcc.gnu.org
Mon Sep 6 18:39:13 GMT 2021


https://gcc.gnu.org/g:5bfb794ae1bef72e251b5aa7274e79b3034bb1bc

commit r9-9709-g5bfb794ae1bef72e251b5aa7274e79b3034bb1bc
Author: Paul Thomas <pault@gcc.gnu.org>
Date:   Fri Jan 8 10:15:22 2021 +0000

    Fortran: Allow pointer deferred length associate selectors. [PR93794]
    
    2021-01-05  Paul Thomas  <pault@gcc.gnu.org>
    
    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.
    
    (cherry picked from commit 21c1a30fc73105af50c5e717cb99dc3becabf8fa)

Diff:
---
 gcc/fortran/trans-expr.c                            |  2 +-
 gcc/testsuite/gfortran.dg/deferred_character_35.f90 | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 59ffd071430..6250450842a 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -2664,7 +2664,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  <gscfq@t-online.de>
+!
+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


More information about the Gcc-cvs mailing list