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.
This commit is contained in:
Tobias Burnus 2021-02-19 18:05:31 +01:00
parent c8d1383563
commit 72d91d6cd4
2 changed files with 36 additions and 1 deletions

View File

@ -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;

View File

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