2006-03-28 Paul Thomas <pault@gcc.gnu.org>
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 28 Mar 2006 10:13:50 +0000 (10:13 +0000)
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 28 Mar 2006 10:13:50 +0000 (10:13 +0000)
PR fortran/26779
*resolve.c (resolve_fl_procedure): Do not check the access of
derived types for internal procedures.

2006-03-28 Paul Thomas <pault@gcc.gnu.org>

PR fortran/26779
* gfortran.dg/private_type_5.f90: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@112442 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/private_type_5.f90 [new file with mode: 0644]

index 6d19805..d2a1e4f 100644 (file)
@@ -1,3 +1,9 @@
+2006-03-28 Paul Thomas <pault@gcc.gnu.org>
+
+       PR fortran/26779
+       *resolve.c (resolve_fl_procedure): Do not check the access of
+       derived types for internal procedures.
+
 2006-03-27  Jakub Jelinek  <jakub@redhat.com>
 
        * io.c (check_io_constraints): Don't look at
index 548b67e..562338f 100644 (file)
@@ -4834,9 +4834,13 @@ resolve_fl_procedure (gfc_symbol *sym, int mp_flag)
         }
     }
 
-  /* Ensure that derived type formal arguments of a public procedure
-     are not of a private type.  */
-  if (gfc_check_access(sym->attr.access, sym->ns->default_access))
+  /* Ensure that derived type for are not of a private type.  Internal
+     module procedures are excluded by 2.2.3.3 - ie. they are not
+     externally accessible and can access all the objects accesible in
+     the host. */
+  if (!(sym->ns->parent
+           && sym->ns->parent->proc_name->attr.flavor == FL_MODULE)
+       && gfc_check_access(sym->attr.access, sym->ns->default_access))
     {
       for (arg = sym->formal; arg; arg = arg->next)
        {
index 539c2a8..c2383d2 100644 (file)
@@ -1,3 +1,8 @@
+2006-03-28 Paul Thomas <pault@gcc.gnu.org>
+
+       PR fortran/26779
+       * gfortran.dg/private_type_5.f90: New test.
+
 2006-03-27  David Edelsohn  <edelsohn@gnu.org>
 
        * objc.dg/objc-nofilename-1.m: Limit to Darwin.
diff --git a/gcc/testsuite/gfortran.dg/private_type_5.f90 b/gcc/testsuite/gfortran.dg/private_type_5.f90
new file mode 100644 (file)
index 0000000..e62fe6e
--- /dev/null
@@ -0,0 +1,24 @@
+! { dg-do compile }
+! Tests the fix for PR26779, where an error would occur because
+! init was detected to be public with a private type dummy argument.
+!
+! Contributed by Paul Thomas  <pault@gcc.gnu.org>
+!
+module test
+  public sub
+  type, private :: t
+    integer :: i
+  end type t
+contains
+  subroutine sub (arg)
+    integer arg
+    type(t) :: root
+    call init(root, arg)
+  contains
+    subroutine init(ir, i)
+      integer i
+      type(t) :: ir
+      ir%i = i
+    end subroutine init
+  end subroutine sub
+end module test
\ No newline at end of file