public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-10076] Fortran: Allow pointer deferred length associate selectors. [PR93794]
@ 2021-08-28 19:49 Harald Anlauf
  0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2021-08-28 19:49 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:803918dc6da9b7c88cc97635fc8a21bbd805a120

commit r10-10076-g803918dc6da9b7c88cc97635fc8a21bbd805a120
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 cb901437965..dbe6344db99 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  <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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-28 19:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-28 19:49 [gcc r10-10076] Fortran: Allow pointer deferred length associate selectors. [PR93794] Harald Anlauf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).