brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 474b07c Raw
77 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! Tests for I/O of derived types without defined I/O procedures3! but with exposed allocatable/pointer components that would fail4! at run time.5 6module m17  type :: poison8    real, allocatable :: allocatableComponent(:)9  end type10  type :: ok11    integer :: x12    type(poison) :: pill13   contains14    procedure :: wuf115    generic :: write(unformatted) => wuf116  end type17  type :: maybeBad18    integer :: x19    type(poison) :: pill20  end type21 contains22  subroutine wuf1(dtv, unit, iostat, iomsg)23    class(ok), intent(in) :: dtv24    integer, intent(in) :: unit25    integer, intent(out) :: iostat26    character(*), intent(in out) :: iomsg27    write(unit) dtv%x28  end subroutine29end module30 31module m232  use m133  interface write(unformatted)34    module procedure wuf235  end interface36 contains37  subroutine wuf2(dtv, unit, iostat, iomsg)38    class(maybeBad), intent(in) :: dtv39    integer, intent(in) :: unit40    integer, intent(out) :: iostat41    character(*), intent(in out) :: iomsg42    write(unit) dtv%x43  end subroutine44end module45 46module m347  use m148 contains49  subroutine test3(u)50    integer, intent(in) :: u51    type(ok) :: x52    type(maybeBad) :: y53    type(poison) :: z54    write(u) x ! always ok55    !ERROR: Derived type 'maybebad' in I/O cannot have an allocatable or pointer direct component 'allocatablecomponent' unless using defined I/O56    write(u) y ! bad here57    !ERROR: Derived type 'poison' in I/O cannot have an allocatable or pointer direct component 'allocatablecomponent' unless using defined I/O58    write(u) z ! bad59  end subroutine60end module61 62module m463  use m264 contains65  subroutine test4(u)66    integer, intent(in) :: u67    type(ok) :: x68    type(maybeBad) :: y69    type(poison) :: z70    write(u) x ! always ok71    write(u) y ! ok here72    !ERROR: Derived type 'poison' in I/O cannot have an allocatable or pointer direct component 'allocatablecomponent' unless using defined I/O73    write(u) z ! bad74  end subroutine75end module76 77