From 60e85f7367c6735336a479147cc80d1285f9fc92 Mon Sep 17 00:00:00 2001 From: dfranke Date: Tue, 7 Aug 2007 10:18:48 +0000 Subject: [PATCH] 2007-08-07 Daniel Franke * gfortran.dg/namelist_33.f90: Improved tests, adjusted error messages. * gfortran.dg/namelist_36.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127268 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/ChangeLog | 6 +++++ gcc/testsuite/gfortran.dg/namelist_33.f90 | 42 ++++++++++++++++++++++++++----- gcc/testsuite/gfortran.dg/namelist_36.f90 | 29 +++++++++++++++++++++ 3 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/namelist_36.f90 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 + + * gfortran.dg/namelist_33.f90: Improved tests, adjusted error + messages. + * gfortran.dg/namelist_36.f90: New test. + 2007-08-07 Rask Ingemann Lambertsen * 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" } } -- 2.11.0