Merge from mainline.
[official-gcc.git] / gcc / testsuite / gfortran.dg / der_io_2.f90
blob09878b690e91ec8324ec39c56df7f66849c8e072
1 ! { dg-do compile }
2 ! PR 23843
3 ! IO of derived types with private components is allowed in the module itself,
4 ! but not elsewhere
5 module gfortran2
6 type :: tp1
7 private
8 integer :: i
9 end type tp1
11 type :: tp1b
12 integer :: i
13 end type tp1b
15 type :: tp2
16 real :: a
17 type(tp1) :: t
18 end type tp2
20 contains
22 subroutine test()
23 type(tp1) :: x
24 type(tp2) :: y
26 write (*, *) x
27 write (*, *) y
28 end subroutine test
30 end module gfortran2
32 program prog
34 use gfortran2
36 implicit none
37 type :: tp3
38 type(tp2) :: t
39 end type tp3
40 type :: tp3b
41 type(tp1b) :: t
42 end type tp3b
44 type(tp1) :: x
45 type(tp2) :: y
46 type(tp3) :: z
47 type(tp3b) :: zb
49 write (*, *) x ! { dg-error "PRIVATE components" }
50 write (*, *) y ! { dg-error "PRIVATE components" }
51 write (*, *) z ! { dg-error "PRIVATE components" }
52 write (*, *) zb
53 end program prog
55 ! { dg-final { cleanup-modules "gfortran2" } }