2014-04-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gfortran.dg / namelist_33.f90
blob79459eecef7fb3f8057090da2ad384f21b5828a0
1 ! { dg-do compile }
3 ! PR fortran/32876 - accepts private items in public NAMELISTs
5 ! USE-associated types with private components may
6 ! not be used in namelists -- anywhere.
8 MODULE types
9 type :: tp4
10 PRIVATE
11 real :: x
12 integer :: i
13 end type
15 ! nested type
16 type :: tp3
17 real :: x
18 integer, private :: i
19 end type
21 type :: tp2
22 type(tp3) :: t
23 end type
25 type :: tp1
26 integer :: i
27 type(tp2) :: t
28 end type
29 END MODULE
31 MODULE nml
32 USE types
34 type(tp1) :: t1
35 type(tp4) :: t4
37 namelist /a/ t1 ! { dg-error "use-associated PRIVATE components" }
38 namelist /b/ t4 ! { dg-error "use-associated PRIVATE components" }
40 integer, private :: i
41 namelist /c/ i ! { dg-error "was declared PRIVATE and cannot be member of PUBLIC namelist" }
43 contains
44 subroutine y()
45 type(tp2) :: y2
46 type(tp3) :: y3
48 namelist /nml2/ y2 ! { dg-error "has use-associated PRIVATE components " }
49 namelist /nml3/ y3 ! { dg-error "has use-associated PRIVATE components " }
50 end subroutine
51 END MODULE
54 program xxx
55 use types
57 type :: tp5
58 TYPE(tp4) :: t ! nested private components
59 end type
60 type(tp5) :: t5
62 namelist /nml/ t5 ! { dg-error "has use-associated PRIVATE components" }
64 contains
65 subroutine z()
66 namelist /nml2/ t5 ! { dg-error "has use-associated PRIVATE components" }
67 end subroutine
68 end program