public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch] Fortran: Fix DTIO with type ICE [PR99146]
@ 2021-02-19 16:00 Tobias Burnus
  2021-02-19 16:22 ` Jerry DeLisle
  0 siblings, 1 reply; 2+ messages in thread
From: Tobias Burnus @ 2021-02-19 16:00 UTC (permalink / raw)
  To: gcc-patches, fortran, Jerry DeLisle

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

In this example, the formal argument is a derived type
and not a class – hence, there is an ICE.

OK for the trunk?

Tobias

-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf

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

Fortran: Fix DTIO with type ICE [PR99146]

gcc/fortran/ChangeLog:

	PR fortran/99146
	* interface.c:

gcc/testsuite/ChangeLog:

	PR fortran/99146
	* gfortran.dg/dtio_36.f90: New test.

 gcc/fortran/interface.c               |  4 +++-
 gcc/testsuite/gfortran.dg/dtio_36.f90 | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index 87fe14280e6..f7ca52e6550 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -5305,7 +5305,9 @@ gfc_find_specific_dtio_proc (gfc_symbol *derived, bool write, bool formatted)
     }
 
 finish:
-  if (dtio_sub && derived != CLASS_DATA (dtio_sub->formal->sym)->ts.u.derived)
+  if (dtio_sub
+      && dtio_sub->formal->sym->ts.type == BT_CLASS
+      && derived != CLASS_DATA (dtio_sub->formal->sym)->ts.u.derived)
     gfc_find_derived_vtab (derived);
 
   return dtio_sub;
diff --git a/gcc/testsuite/gfortran.dg/dtio_36.f90 b/gcc/testsuite/gfortran.dg/dtio_36.f90
new file mode 100644
index 00000000000..4e53581b86a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/dtio_36.f90
@@ -0,0 +1,33 @@
+! { dg-do compile }
+!
+! PR fortran/99146
+!
+      MODULE p
+      TYPE :: person
+      sequence
+      END TYPE person
+      INTERFACE READ(UNFORMATTED)
+       MODULE PROCEDURE pruf
+      END INTERFACE
+
+      CONTAINS
+
+      SUBROUTINE pruf (dtv,unit,iostat,iomsg)
+       type(person), INTENT(INOUT) :: dtv
+       INTEGER, INTENT(IN) :: unit
+       INTEGER, INTENT(OUT) :: iostat
+       CHARACTER (LEN=*), INTENT(INOUT) :: iomsg
+       iostat = 1
+      END SUBROUTINE pruf
+
+      END MODULE p
+
+      PROGRAM test
+      USE p
+      TYPE (person) :: chairman
+
+      OPEN (UNIT=71, status = 'scratch', FORM='UNFORMATTED')
+
+      read(71) chairman
+
+      END PROGRAM test

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

* Re: [Patch] Fortran: Fix DTIO with type ICE [PR99146]
  2021-02-19 16:00 [Patch] Fortran: Fix DTIO with type ICE [PR99146] Tobias Burnus
@ 2021-02-19 16:22 ` Jerry DeLisle
  0 siblings, 0 replies; 2+ messages in thread
From: Jerry DeLisle @ 2021-02-19 16:22 UTC (permalink / raw)
  To: Tobias Burnus, gcc-patches, fortran



On 2/19/21 8:00 AM, Tobias Burnus wrote:
> In this example, the formal argument is a derived type
> and not a class – hence, there is an ICE.
>
> OK for the trunk?
>
This is OK, could you also check 89219 and 81499 and see if these are 
the same or similar.

Much appreciated.

Jerry

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

end of thread, other threads:[~2021-02-19 16:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-19 16:00 [Patch] Fortran: Fix DTIO with type ICE [PR99146] Tobias Burnus
2021-02-19 16:22 ` Jerry DeLisle

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).