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]

Re: [Patch, fortran] PR24207 (and PR21896) - incorrect applicationof private attribute.


:ADDPATCH fortran:

This patch fixes PR24207, in which a private variable was being denied a namelist in a contained procedure in the same module, and an over zealous patch for PR21986, which did the same for use associated derived type arguments in a public procedure. In the case of contained namelists, both use associated and host associated symbols must be permitted, whereas only use associated symbols are permitted for public procedures. Trying to use associate private symbols is caught elesewhere. The patch modifies the appropriate conditions in resolve.c (resolve_symbol).

Bubblestrapped and regtested on Cygwin_NT/Athlon. OK for mainline and 4.0?

Paul T




2005-10-07  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/24207
	* resolve.c (resolve_symbol): Exclude use and host associated
	symbols from the test for private objects in a public namelist.

2005-10-07  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/24207
	gfortran.dg/private_type_3.f90: New test.


*** gcc/gcc/fortran/resolve.c.wrong	Wed Oct  5 10:43:32 2005
--- gcc/gcc/fortran/resolve.c	Thu Oct  6 09:29:36 2005
*************** resolve_symbol (gfc_symbol * sym)
*** 4330,4335 ****
--- 4330,4336 ----
  	{
  	  if (arg->sym
  		&& arg->sym->ts.type == BT_DERIVED
+ 		&& !arg->sym->ts.derived->attr.use_assoc
  		&& !gfc_check_access(arg->sym->ts.derived->attr.access,
  				     arg->sym->ts.derived->ns->default_access))
  	    {
*************** resolve_symbol (gfc_symbol * sym)
*** 4432,4438 ****
  	{
  	  for (nl = sym->namelist; nl; nl = nl->next)
  	    {
! 	      if (!gfc_check_access(nl->sym->attr.access,
  				    nl->sym->ns->default_access))
  		gfc_error ("PRIVATE symbol '%s' cannot be member of "
  			   "PUBLIC namelist at %L", nl->sym->name,
--- 4433,4443 ----
  	{
  	  for (nl = sym->namelist; nl; nl = nl->next)
  	    {
! 	      if (!nl->sym->attr.use_assoc
! 		    &&
! 		  !(sym->ns->parent == nl->sym->ns)
! 		    &&
! 		  !gfc_check_access(nl->sym->attr.access,
  				    nl->sym->ns->default_access))
  		gfc_error ("PRIVATE symbol '%s' cannot be member of "
  			   "PUBLIC namelist at %L", nl->sym->name,


----------------private_type_3.f90-----------------

! { dg-do compile }
! { dg-options "-O0" }
! Tests the fix for PR24207 and the problems associated
! with the fix for PR21986. In two cases, use associated
! public symbols were taking on the default private access
! attribute of the local namespace. In the third, a private
! symbol was not available to a namelist in contained 
! procedure in the same module.
!
! Based on the example in PR24207.
!
module a
  implicit none
  real b
  type :: mytype
    integer :: c
  end type mytype
end module a
module c
  use a
  implicit none
  public d
  private
  real x
  contains
     subroutine d (arg_t)   ! This would cause an error
        type (mytype) :: arg_t
        namelist /e/ b, x   ! .... as would this.
        read(5,e)
        arg_t%c = 42
     end subroutine d
end module c

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