namelist_33.f90: Improved tests, adjusted error messages.
authorDaniel Franke <franke.daniel@gmail.com>
Tue, 7 Aug 2007 10:18:48 +0000 (06:18 -0400)
committerDaniel Franke <dfranke@gcc.gnu.org>
Tue, 7 Aug 2007 10:18:48 +0000 (06:18 -0400)
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

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/namelist_33.f90
gcc/testsuite/gfortran.dg/namelist_36.f90 [new file with mode: 0644]

index 2a93620d1932f3cfd610b6376d5d9750f10da786..6d61a777092a8315921c2594c847032874050b81 100644 (file)
@@ -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
index 1642389735a0174439c504f58cf80ce556b81335..8bbe59715edd5b3201e6693c442b2bfd3ee0fcad 100644 (file)
@@ -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 (file)
index 0000000..61e88b6
--- /dev/null
@@ -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" } }