2017-12-08 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gfortran.dg / der_io_2.f90
blobe102a97a5755e23989a9052a4cee44866f6a4425
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