public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, fortran] PR103366 - [9/10/11/12 Regression] ICE in gfc_conv_gfc_desc_to_cfi_desc, at fortran/trans-expr.c:5647
@ 2022-01-07 13:42 Paul Richard Thomas
  2022-01-07 21:05 ` Harald Anlauf
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Richard Thomas @ 2022-01-07 13:42 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 691 bytes --]

I doubt that this is a regression on 9-11 branches since the testcase
compiles correctly on each of my copies of these branches. IMHO it is
rather more likely to have been caused by
64f9623765da3306b0ab6a47997dc5d62c2ea261, which introduced this new form of
gfc_conv_gfc_desc_to_cfi_desc.

The patch is self-explanatory. OK for mainline?

Paul

Fortran: Match unlimited polymorphic argument to assumed type [PR103366].

2022-01-07  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/103366
* trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): Allow unlimited
polymorphic actual argument passed to assumed type formal.

gcc/testsuite/
PR fortran/103366
* gfortran.dg/pr103366.f90: New test.

[-- Attachment #2: pr103366.diff --]
[-- Type: text/x-patch, Size: 1486 bytes --]

diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 381915e2a76..2e15a7e874c 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -50,10 +50,10 @@ static tree
 gfc_get_character_len (tree type)
 {
   tree len;
-  
+
   gcc_assert (type && TREE_CODE (type) == ARRAY_TYPE
 	      && TYPE_STRING_FLAG (type));
-  
+
   len = TYPE_MAX_VALUE (TYPE_DOMAIN (type));
   len = (len) ? (len) : (integer_zero_node);
   return fold_convert (gfc_charlen_type_node, len);
@@ -67,10 +67,10 @@ tree
 gfc_get_character_len_in_bytes (tree type)
 {
   tree tmp, len;
-  
+
   gcc_assert (type && TREE_CODE (type) == ARRAY_TYPE
 	      && TYPE_STRING_FLAG (type));
-  
+
   tmp = TYPE_SIZE_UNIT (TREE_TYPE (type));
   tmp = (tmp && !integer_zerop (tmp))
     ? (fold_convert (gfc_charlen_type_node, tmp)) : (NULL_TREE);
@@ -5630,6 +5630,16 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym)
 	  itype = CFI_type_other;  // FIXME: Or CFI_type_cptr ?
 	  break;
 	case BT_CLASS:
+	  if (UNLIMITED_POLY (e) && fsym->ts.type == BT_ASSUMED)
+	    {
+	      // F2017: 7.3.2.2: "An entity that is declared using the TYPE(*)
+	      // type specifier is assumed-type and is an unlimited polymorphic
+	      //  entity." The actual argument _data component is passed.
+	      itype = CFI_type_other;  // FIXME: Or CFI_type_cptr ?
+	      break;
+	    }
+	  else
+	    gcc_unreachable ();
 	case BT_PROCEDURE:
 	case BT_HOLLERITH:
 	case BT_UNION:

[-- Attachment #3: pr103366.f90 --]
[-- Type: text/x-fortran, Size: 299 bytes --]

! { dg-do compile }
!
! Test the fix for PR103366.
!
! Contributed by Gerhardt Steinmetz  <gscfq@t-online.de>
!
program p
  call u([1])
contains
   subroutine s(x) bind(c)
      type(*) :: x(..)
   end
   subroutine u(x)
      class(*) :: x(..)
      call s(x)         ! Used to ICE here
   end
end

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch, fortran] PR103366 - [9/10/11/12 Regression] ICE in gfc_conv_gfc_desc_to_cfi_desc, at fortran/trans-expr.c:5647
  2022-01-07 13:42 [Patch, fortran] PR103366 - [9/10/11/12 Regression] ICE in gfc_conv_gfc_desc_to_cfi_desc, at fortran/trans-expr.c:5647 Paul Richard Thomas
@ 2022-01-07 21:05 ` Harald Anlauf
  2022-01-07 21:05   ` Harald Anlauf
  0 siblings, 1 reply; 3+ messages in thread
From: Harald Anlauf @ 2022-01-07 21:05 UTC (permalink / raw)
  To: Paul Richard Thomas, fortran, gcc-patches

Hi Paul,

Am 07.01.22 um 14:42 schrieb Paul Richard Thomas via Fortran:
> I doubt that this is a regression on 9-11 branches since the testcase
> compiles correctly on each of my copies of these branches. IMHO it is
> rather more likely to have been caused by
> 64f9623765da3306b0ab6a47997dc5d62c2ea261, which introduced this new form of
> gfc_conv_gfc_desc_to_cfi_desc.
>
> The patch is self-explanatory. OK for mainline?

I do not have a copy of F2017; but I can find your comment in the F2018
document.

OK with this change.

Thanks for the patch!

Harald

> Paul
>
> Fortran: Match unlimited polymorphic argument to assumed type [PR103366].
>
> 2022-01-07  Paul Thomas  <pault@gcc.gnu.org>
>
> gcc/fortran
> PR fortran/103366
> * trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): Allow unlimited
> polymorphic actual argument passed to assumed type formal.
>
> gcc/testsuite/
> PR fortran/103366
> * gfortran.dg/pr103366.f90: New test.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch, fortran] PR103366 - [9/10/11/12 Regression] ICE in gfc_conv_gfc_desc_to_cfi_desc, at fortran/trans-expr.c:5647
  2022-01-07 21:05 ` Harald Anlauf
@ 2022-01-07 21:05   ` Harald Anlauf
  0 siblings, 0 replies; 3+ messages in thread
From: Harald Anlauf @ 2022-01-07 21:05 UTC (permalink / raw)
  To: fortran; +Cc: gcc-patches

Hi Paul,

Am 07.01.22 um 14:42 schrieb Paul Richard Thomas via Fortran:
> I doubt that this is a regression on 9-11 branches since the testcase
> compiles correctly on each of my copies of these branches. IMHO it is
> rather more likely to have been caused by
> 64f9623765da3306b0ab6a47997dc5d62c2ea261, which introduced this new form of
> gfc_conv_gfc_desc_to_cfi_desc.
> 
> The patch is self-explanatory. OK for mainline?

I do not have a copy of F2017; but I can find your comment in the F2018
document.

OK with this change.

Thanks for the patch!

Harald

> Paul
> 
> Fortran: Match unlimited polymorphic argument to assumed type [PR103366].
> 
> 2022-01-07  Paul Thomas  <pault@gcc.gnu.org>
> 
> gcc/fortran
> PR fortran/103366
> * trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): Allow unlimited
> polymorphic actual argument passed to assumed type formal.
> 
> gcc/testsuite/
> PR fortran/103366
> * gfortran.dg/pr103366.f90: New test.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-07 21:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-07 13:42 [Patch, fortran] PR103366 - [9/10/11/12 Regression] ICE in gfc_conv_gfc_desc_to_cfi_desc, at fortran/trans-expr.c:5647 Paul Richard Thomas
2022-01-07 21:05 ` Harald Anlauf
2022-01-07 21:05   ` 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).