]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/26779 (Internal module procedure may not have private type dummy arguments)
authorPaul Thomas <pault@gcc.gnu.org>
Tue, 28 Mar 2006 10:13:50 +0000 (10:13 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Tue, 28 Mar 2006 10:13:50 +0000 (10:13 +0000)
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-28 Paul Thomas <pault@gcc.gnu.org>

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

From-SVN: r112442

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

index 6d19805ee6660b9170d3ff6f03aa2c011c4ac0e3..d2a1e4fc66dd5c1d164c9d3164cba86923a8eaab 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 548b67ef7c5bb4d83e22b5c9528ced6400d764ab..562338fdb6454d0e50fd2750ebee126b2ca4351e 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 539c2a821ca1843c14db1750888d0e577a5b6396..c2383d247b5db5b1fda5a27eb0228b0149e7f3d4 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