[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Semantics / io14.f90
blob6dd6763bc944b93fdf1abfc392dc64d04315f353
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Test polymorphic restrictions
3 module m
4 type base
5 end type
6 type, extends(base) :: t
7 integer n
8 contains
9 procedure :: fwrite
10 generic :: write(formatted) => fwrite
11 end type
12 contains
13 subroutine fwrite(x, unit, iotype, vlist, iostat, iomsg)
14 class(t), intent(in) :: x
15 integer, intent(in) :: unit
16 character(*), intent(in) :: iotype
17 integer, intent(in) :: vlist(:)
18 integer, intent(out) :: iostat
19 character(*), intent(in out) :: iomsg
20 write(unit, *, iostat=iostat, iomsg=iomsg) '(', iotype, ':', vlist, ':', x%n, ')'
21 end subroutine
22 subroutine subr(x, y, z)
23 class(t), intent(in) :: x
24 class(base), intent(in) :: y
25 class(*), intent(in) :: z
26 print *, x ! ok
27 !ERROR: Derived type 'base' in I/O may not be polymorphic unless using defined I/O
28 print *, y
29 !ERROR: I/O list item may not be unlimited polymorphic
30 print *, z
31 end subroutine
32 end
34 program main
35 use m
36 call subr(t(123),t(234),t(345))
37 end