Issue |
154130
|
Summary |
[flang] Fail to select the more specific type guard statement within DTIO.
|
Labels |
flang:frontend
|
Assignees |
|
Reporter |
DanielCChen
|
Consider the following reducer:
```
module m
type, abstract :: abstractdata
end type
type, extends(abstractdata) :: data
integer(4) :: i = -999
end type
type :: base
character(3) :: c = 'xxx'
class(abstractdata), allocatable :: d
end type
interface read(formatted)
subroutine readformatted(dtv, unit, iotype, v_list, iostat, iomsg )
import base
class(base), intent(inout) :: dtv
integer, intent(in) :: unit
character(*), intent(in) :: iotype
integer, intent(in) :: v_list(:)
integer, intent(out) :: iostat
character(*), intent(inout) :: iomsg
end subroutine
subroutine readformatteddata(dtv, unit, iotype, v_list, iostat, iomsg )
import data
class(abstractdata), intent(inout) :: dtv
integer, intent(in) :: unit
character(*), intent(in) :: iotype
integer, intent(in) :: v_list(:)
integer, intent(out) :: iostat
character(*), intent(inout) :: iomsg
end subroutine
end interface
end module m
program main
use m
type(base) :: b1(2)
type(base), allocatable :: b2(:)
namelist /nml1/ b1
integer :: stat
character(200) :: msg = ''
open (1, file = 'data.1', form='formatted', access='sequential' )
b1 = (/ base(d=data()), base(d=data()) /)
read (1,NML=nml1, iostat=stat, iomsg=msg)
if ( stat /= 0 ) error stop 1
end program main
subroutine readformatted (dtv, unit, iotype, v_list, iostat, iomsg)
use m, only: base, abstractdata, read(formatted), readformatteddata
class(base), intent(inout) :: dtv
integer, intent(in) :: unit
character(*), intent(in) :: iotype
integer, intent(in) :: v_list(:)
integer, intent(out) :: iostat
character(*), intent(inout) :: iomsg
class(abstractdata), allocatable :: x1
namelist /dtio/ x1 !! Nested namelist
read (unit, *, iostat=iostat, iomsg=iomsg ) dtv%c
allocate ( x1, source = dtv%d )
read (unit, dtio, iostat=iostat, iomsg = iomsg )
end subroutine
subroutine readformatteddata (dtv, unit, iotype, v_list, iostat, iomsg)
use m, only: abstractdata, data
class(abstractdata), intent(inout) :: dtv
integer, intent(in) :: unit
character(*), intent(in) :: iotype
integer, intent(in) :: v_list(:)
integer, intent(out) :: iostat
character(*), intent(inout) :: iomsg
select type ( dtv )
class is (abstractdata)
error stop 22
type is (data)
read (unit, *, iostat=iostat, iomsg=iomsg ) dtv%i
end select
end subroutine
```
Flang failed at:
```
> a.out
Fortran ERROR STOP: code 22
```
`dtv` has dynamic type `data`. It seems Flang failed to choose the more specific type guard statement of `type is (data)` within an DTIO procedure.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs