diff options
author | Daniel Franke <franke.daniel@gmail.com> | 2007-08-07 06:18:48 -0400 |
---|---|---|
committer | Daniel Franke <dfranke@gcc.gnu.org> | 2007-08-07 06:18:48 -0400 |
commit | d2b8fb9e4661b4181548cfaa437c65788fe640f2 (patch) | |
tree | c54c7ff728bf241314113014987c09240acd5493 | |
parent | 6268a9a863b023c9cee76fe45e98c523ade7a360 (diff) | |
download | gcc-d2b8fb9e4661b4181548cfaa437c65788fe640f2.zip gcc-d2b8fb9e4661b4181548cfaa437c65788fe640f2.tar.gz gcc-d2b8fb9e4661b4181548cfaa437c65788fe640f2.tar.bz2 |
namelist_33.f90: Improved tests, adjusted error messages.
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.
From-SVN: r127268
-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 2a93620..6d61a77 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 1642389..8bbe597 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 0000000..61e88b6 --- /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" } } |