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]

[Patch, fortran] PR24866 - ICE on external dummy in module procedure


:ADDPATCH fortran:

If this comes through twice, I apologise - I apparently sent it OK last night but I have not seen it on the list.

If an external dummy procedure in a module procedure has a doppelganger module procedure, with the same name, an ICE can ensue, depending on the ordering of the module procedures. This comes about because parse.c (gfc_fixup_sibling_symbols) tries to redirect the symtree reference for the dummy to the host associated symbol for the doppelganger. The fix is easy, as will be seen from the patch. The testsuite case is a developed version of the contributors example.

Regtested on SUSE10.1/AMD64 - OK for trunk and 4.1?

Paul

2006-08-19 Paul Thomas <pault@gcc.gnu.org>

  PR fortran/24866
  * parse.c (gfc_fixup_sibling_symbols): Do not modify the symbol
  if it is a dummy in the contained namespace.

2006-08-19 Paul Thomas <pault@gcc.gnu.org>

  PR fortran/24866
  * gfortran.dg/module_proc_external_dummy.f90: New test.
Index: gcc/testsuite/gfortran.dg/module_proc_external_dummy.f90
===================================================================
*** gcc/testsuite/gfortran.dg/module_proc_external_dummy.f90	(revision 0)
--- gcc/testsuite/gfortran.dg/module_proc_external_dummy.f90	(revision 0)
***************
*** 0 ****
--- 1,29 ----
+ ! { dg-do compile }
+ ! This tests the fix for PR24866 in which the reference to the external str, in
+ ! sub_module, would get mixed up with the module procedure, str, thus
+ ! causing an ICE.  This is a completed version of the reporter's testcase; ie
+ ! it adds a main program and working subroutines to allow a check for
+ ! correct functioning.
+ !
+ ! Contributed by Uttam Pawar  <uttamp@us.ibm.com>
+ !
+    subroutine sub()
+      print *, "external sub"
+    end subroutine sub
+ 
+ module test_module
+  contains
+    subroutine sub_module(str)
+      external :: str
+      call str ()
+    end subroutine sub_module
+    subroutine str()
+      print *, "module str"
+    end subroutine str
+ end module test_module
+ 
+    use test_module
+    external sub
+    call sub_module (sub)
+    call sub_module (str)
+ end
Index: gcc/fortran/parse.c
===================================================================
*** gcc/fortran/parse.c	(revision 116226)
--- gcc/fortran/parse.c	(working copy)
*************** gfc_fixup_sibling_symbols (gfc_symbol * 
*** 2706,2713 ****
    for (ns = siblings; ns; ns = ns->sibling)
      {
        gfc_find_sym_tree (sym->name, ns, 0, &st);
!       if (!st)
!         continue;
  
        old_sym = st->n.sym;
        if ((old_sym->attr.flavor == FL_PROCEDURE
--- 2706,2714 ----
    for (ns = siblings; ns; ns = ns->sibling)
      {
        gfc_find_sym_tree (sym->name, ns, 0, &st);
! 
!       if (!st || (st->n.sym->attr.dummy && ns == st->n.sym->ns))
! 	continue;
  
        old_sym = st->n.sym;
        if ((old_sym->attr.flavor == FL_PROCEDURE
2006-08-19  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/24866
	* parse.c (gfc_fixup_sibling_symbols): Do not modify the symbol
	if it is a dummy in the contained namespace.

2006-08-19  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/24866
	* gfortran.dg/module_proc_external_dummy.f90: New test.

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