public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tobias Burnus <tobias@codesourcery.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>,
	fortran <fortran@gcc.gnu.org>,
	Jerry DeLisle <jvdelisle@charter.net>
Subject: [Patch] Fortran: Fix DTIO with type ICE [PR99146]
Date: Fri, 19 Feb 2021 17:00:27 +0100	[thread overview]
Message-ID: <e23ed6a5-3504-ea0b-ce38-1b2f8a7c5198@codesourcery.com> (raw)

[-- 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

             reply	other threads:[~2021-02-19 16:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-19 16:00 Tobias Burnus [this message]
2021-02-19 16:22 ` Jerry DeLisle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e23ed6a5-3504-ea0b-ce38-1b2f8a7c5198@codesourcery.com \
    --to=tobias@codesourcery.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jvdelisle@charter.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).