diff options
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/namelist_33.f90 | 42 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/namelist_36.f90 | 29 |
3 files changed, 71 insertions, 6 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2a93620d193..6d61a777092 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2007-08-07 Daniel Franke <franke.daniel@gmail.com> + + * gfortran.dg/namelist_33.f90: Improved tests, adjusted error + messages. + * gfortran.dg/namelist_36.f90: New test. + 2007-08-07 Rask Ingemann Lambertsen <rask@sygehus.dk> * gcc.c-torture/execute/simd-4.c (__ev_convert_s64)(main): Use diff --git a/gcc/testsuite/gfortran.dg/namelist_33.f90 b/gcc/testsuite/gfortran.dg/namelist_33.f90 index 1642389735a..8bbe59715ed 100644 --- a/gcc/testsuite/gfortran.dg/namelist_33.f90 +++ b/gcc/testsuite/gfortran.dg/namelist_33.f90 @@ -2,6 +2,9 @@ ! ! PR fortran/32876 - accepts private items in public NAMELISTs ! +! USE-associated types with private components may +! not be used in namelists -- anywhere. +! MODULE types type :: tp4 PRIVATE @@ -26,15 +29,42 @@ MODULE types END MODULE MODULE nml -USE types - type(tp1) :: t1 - type(tp4) :: t4 + USE types + + type(tp1) :: t1 + type(tp4) :: t4 - namelist /a/ t1 ! { dg-error "has PRIVATE components and cannot be a member of PUBLIC namelist" } - namelist /b/ t4 ! { dg-error "has PRIVATE components and cannot be a member of PUBLIC namelist" } + namelist /a/ t1 ! { dg-error "use-associated PRIVATE components" } + namelist /b/ t4 ! { dg-error "use-associated PRIVATE components" } integer, private :: i - namelist /c/ i ! { dg-error "was declared PRIVATE and cannot be member of PUBLIC namelist" } + namelist /c/ i ! { dg-error "was declared PRIVATE and cannot be member of PUBLIC namelist" } + +contains + subroutine y() + type(tp2) :: y2 + type(tp3) :: y3 + + namelist /nml2/ y2 ! { dg-error "has use-associated PRIVATE components " } + namelist /nml3/ y3 ! { dg-error "has use-associated PRIVATE components " } + end subroutine END MODULE + +program xxx + use types + + type :: tp5 + TYPE(tp4) :: t ! nested private components + end type + type(tp5) :: t5 + + namelist /nml/ t5 ! { dg-error "has use-associated PRIVATE components" } + +contains + subroutine z() + namelist /nml2/ t5 ! { dg-error "has use-associated PRIVATE components" } + end subroutine +end program + ! { dg-final { cleanup-modules "types nml" } } diff --git a/gcc/testsuite/gfortran.dg/namelist_36.f90 b/gcc/testsuite/gfortran.dg/namelist_36.f90 new file mode 100644 index 00000000000..61e88b6b3e9 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/namelist_36.f90 @@ -0,0 +1,29 @@ +! { dg-compile } +! +! Private types and types with private components +! are acceptable in local namelists. +! + +MODULE nml + type :: tp1 + integer :: i + end type + + type :: tp2 + private + integer :: i + end type + + private :: tp1 +contains + subroutine x() + type(tp1) :: t1 + type(tp2) :: t2 + + namelist /nml1/ i ! ok, private variable + namelist /nml2/ t1 ! ok, private type + namelist /nml3/ t2 ! ok, private components + end subroutine +END MODULE + +! { dg-final { cleanup-modules "nml" } } |