1! RUN: %python %S/test_errors.py %s %flang_fc1 2! Tests for I/O of derived types without defined I/O procedures 3! but with exposed allocatable/pointer components that would fail 4! at run time. 5 6module m1 7 type :: poison 8 real, allocatable :: allocatableComponent(:) 9 end type 10 type :: ok 11 integer :: x 12 type(poison) :: pill 13 contains 14 procedure :: wuf1 15 generic :: write(unformatted) => wuf1 16 end type 17 type :: maybeBad 18 integer :: x 19 type(poison) :: pill 20 end type 21 contains 22 subroutine wuf1(dtv, unit, iostat, iomsg) 23 class(ok), intent(in) :: dtv 24 integer, intent(in) :: unit 25 integer, intent(out) :: iostat 26 character(*), intent(in out) :: iomsg 27 write(unit) dtv%x 28 end subroutine 29end module 30 31module m2 32 use m1 33 interface write(unformatted) 34 module procedure wuf2 35 end interface 36 contains 37 subroutine wuf2(dtv, unit, iostat, iomsg) 38 class(maybeBad), intent(in) :: dtv 39 integer, intent(in) :: unit 40 integer, intent(out) :: iostat 41 character(*), intent(in out) :: iomsg 42 write(unit) dtv%x 43 end subroutine 44end module 45 46module m3 47 use m1 48 contains 49 subroutine test3(u) 50 integer, intent(in) :: u 51 type(ok) :: x 52 type(maybeBad) :: y 53 type(poison) :: z 54 write(u) x ! always ok 55 !ERROR: Derived type 'maybebad' in I/O cannot have an allocatable or pointer direct component 'allocatablecomponent' unless using defined I/O 56 write(u) y ! bad here 57 !ERROR: Derived type 'poison' in I/O cannot have an allocatable or pointer direct component 'allocatablecomponent' unless using defined I/O 58 write(u) z ! bad 59 end subroutine 60end module 61 62module m4 63 use m2 64 contains 65 subroutine test4(u) 66 integer, intent(in) :: u 67 type(ok) :: x 68 type(maybeBad) :: y 69 type(poison) :: z 70 write(u) x ! always ok 71 write(u) y ! ok here 72 !ERROR: Derived type 'poison' in I/O cannot have an allocatable or pointer direct component 'allocatablecomponent' unless using defined I/O 73 write(u) z ! bad 74 end subroutine 75end module 76 77