This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Ping, Ping [Patch, fortran] PR26779 - Internal module procedure may not have private type dummy arguments


Paul Thomas wrote:

Ping!


This error is generated by the example, given at the end of Metcalf, Reid and
Cohen - pointer.f90. The attached testcase, illustrates the problem:


In the absence of a patch, the following error is produced:

In file private.f90:11

call init(root, arg)
1
Error: 'ir' is of a PRIVATE type and cannot be a dummy argument of 'init',
which is PUBLIC at (1)


Being an internal procedure, init is NOT public by 2.2.3.3 of the F95 standard.
It should have access to all the symbols of its host, therefore this error is
wrong on both levels; ir cannot be private to it, nor is init public!


The patch is easy - simply do not do the test for an internal procedure.

Regtested on FC3/Athlon - OK for trunk and 4.1?

Paul

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

    PR fortran/26779
    *resolve.c (resolve_fl_procedure): Do not check the access of
    components for internal procedures..

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

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



------------------------------------------------------------------------

Index: gcc/fortran/resolve.c
===================================================================
*** gcc/fortran/resolve.c (revision 112211)
--- gcc/fortran/resolve.c (working copy)
*************** resolve_fl_procedure (gfc_symbol *sym, i
*** 4834,4842 ****
}
}
! /* 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))
{
for (arg = sym->formal; arg; arg = arg->next)
{
--- 4834,4846 ----
}
}
! /* 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)
{


------------------------------------------------------------------------

! { 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








Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]