2 ! { dg-options -std=legacy }
4 ! Test elimination of various segfaults and ICEs on error recovery.
6 ! Contributed by Gerhard Steinmetz <gerhard.steinmetz.fortran@t-online.de>
11 interface write(formatted
)
15 subroutine s(dtv
,unit
,iotype
,vlist
,extra
,iostat
,iomsg
) ! { dg-error "Too many dummy arguments" }
16 class(t
), intent(in
) :: dtv
17 integer, intent(in
) :: unit
18 character(len
=*), intent(in
) :: iotype
19 integer, intent(in
) :: vlist(:)
20 integer, intent(out
) :: iostat
21 character(len
=*), intent(inout
) :: iomsg
28 interface read(formatted
)
32 subroutine s(dtv
,unit
,iotype
,vlist
,iostat
,iomsg
,extra
) ! { dg-error "Too many dummy arguments" }
33 class(t
), intent(inout
) :: dtv
34 integer, intent(in
) :: unit
35 character(len
=*), intent(in
) :: iotype
36 integer, intent(in
) :: vlist(:)
37 integer, intent(out
) :: iostat
38 character(len
=*), intent(inout
) :: iomsg
45 interface read(formatted
)
49 subroutine s(dtv
,extra
,unit
,iotype
,vlist
,iostat
,iomsg
) ! { dg-error "Too many dummy arguments" }
50 class(t
), intent(inout
) :: dtv
51 integer, intent(in
) :: unit
52 character(len
=*), intent(in
) :: iotype
53 integer, intent(in
) :: vlist(:)
54 integer, intent(out
) :: iostat
55 character(len
=*), intent(inout
) :: iomsg
62 interface write(unformatted
)
66 subroutine s(*) ! { dg-error "Alternate return" }
74 generic
:: write(unformatted
) => s
77 subroutine s(dtv
, *) ! { dg-error "Too few dummy arguments" }
78 class(t
), intent(out
) :: dtv
84 character(len
=20) :: name
88 generic
:: read(unformatted
) => pruf
91 subroutine pruf (dtv
,unit
,*,iomsg
) ! { dg-error "Alternate return" }
92 class(t
), intent(inout
) :: dtv
93 integer, intent(in
) :: unit
94 character(len
=*), intent(inout
) :: iomsg
95 write (unit
=unit
, iostat
=iostat
, iomsg
=iomsg
) dtv
%name
, dtv
%age
101 character(len
=20) :: name
105 generic
:: read(unformatted
) => pruf
108 subroutine pruf (dtv
,unit
,iostat
) ! { dg-error "Too few dummy arguments" }
109 class(t
), intent(inout
) :: dtv
110 integer, intent(in
) :: unit
111 integer, intent(out
) :: iostat
112 character(len
=1) :: iomsg
113 write (unit
=unit
, iostat
=iostat
, iomsg
=iomsg
) dtv
%name
, dtv
%age
119 character(len
=20) :: name
123 generic
:: read(unformatted
) => pruf
126 subroutine pruf (dtv
,unit
,iostat
,iomsg
)
127 class(t
), intent(inout
) :: dtv
128 integer, intent(in
) :: unit
129 integer, intent(out
) :: iostat
130 character(len
=*), intent(inout
) :: iomsg
131 write (unit
=unit
, iostat
=iostat
, iomsg
=iomsg
) dtv
%name
, dtv
%age
137 class(t
) :: chairman
! { dg-error "must be dummy, allocatable or pointer" }
138 open (unit
=71, file
='myunformatted_data.dat', form
='unformatted')
139 read (71) a
, chairman
, b