This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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]

[Patch, fortran] PR24409 - ICE on module name vs dummy argument name


:ADDPATCH fortran:

This patch represents an adjustment to an earlier one to module.c that hooked up symtree references to one in the non-contained namespace, as soon as it became available. In fact, it did this to excess and was capable of associating symbols to module names or to interface dummy arguments, with disasterous consequences. These errors are easily eliminated, as the attached shows.

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

Paul T

PS The dates are not a mistake; I just forgot about the patch!
2005-10-18  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/24409
	* module.c (mio_symtree_ref): Correct the patch of 0923 so that
	a symbol is not substituted for by a the symbol for the module
	itself and to prevent the promotion of a formal argument.

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

	PR fortran/24409
	gfortran.dg/nested_modules_4.f90: New test.
	gfortran.dg/nested_modules_5.f90: New test.


Index: gcc/gcc/fortran/module.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/module.c,v
retrieving revision 1.40
diff -c -p -r1.40 module.c
*** gcc/gcc/fortran/module.c	23 Sep 2005 17:15:42 -0000	1.40
--- gcc/gcc/fortran/module.c	17 Oct 2005 22:22:36 -0000
*************** mio_symtree_ref (gfc_symtree ** stp)
*** 2100,2108 ****
  	 namespace to see if the required, non-contained symbol is available
  	 yet. If so, the latter should be written.  */
        if ((*stp)->n.sym && check_unique_name((*stp)->name))
! 	ns_st = gfc_find_symtree (gfc_current_ns->sym_root, (*stp)->n.sym->name);
  
!       mio_symbol_ref (ns_st ? &ns_st->n.sym : &(*stp)->n.sym);
      }
    else
      {
--- 2100,2116 ----
  	 namespace to see if the required, non-contained symbol is available
  	 yet. If so, the latter should be written.  */
        if ((*stp)->n.sym && check_unique_name((*stp)->name))
! 	ns_st = gfc_find_symtree (gfc_current_ns->sym_root,
! 				    (*stp)->n.sym->name);
  
!       /* On the other hand, if the existing symbol is the module name or the
! 	 new symbol is a dummy argument, do not do the promotion.  */
!       if (ns_st && ns_st->n.sym
! 	    && ns_st->n.sym->attr.flavor != FL_MODULE
! 	    && !(*stp)->n.sym->attr.dummy)
! 	mio_symbol_ref (&ns_st->n.sym);
!       else
! 	mio_symbol_ref (&(*stp)->n.sym);
      }
    else
      {

-------------------nested_modules_4.f90--------------------

! { dg-do compile }
!
! Test for the fix to PR24409 - the name clash between the module
! name and the interface formal argument would cause an ICE.
!
! Contributed by Paul Thomas  <pault@gcc.gnu.org>
!
module string 
  interface
    function  lc(string )
      character(len=*), intent(in)  :: string 
      character(len=len(string ))    :: lc
    end function lc
  end interface
end module string

module serial
  use string
end module serial

  use serial
  use string
  character*15  :: buffer  
  buffer = lc ("Have a Nice DAY")
  end

-------------------nested_modules_5.f90--------------------

! { dg-do compile }
!
! Test for supplementary fix to PR24409 - the name clash between the module
! variable and the interface formal argument would cause an ICE.
!
! Contributed by Paul Thomas  <pault@gcc.gnu.org>
!
module anything 
  interface
    function  lc(string )
      character(len=*), intent(in)  :: string 
      character(len=len(string ))    :: lc
    end function lc
  end interface
  character(len=12) :: string
end module anything

module serial
  use anything
end module serial

  use serial
  use anything
  character*15  :: buffer  
  buffer = lc ("Have a Nice DAY")
  end

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