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] module that calls a contained function with an ENTRY point


The attached patch resolves an infinite loop and segfault in generic_sym. The result allows the original test case to compile correctly. The attached test case compiles and executes correctly.

I will commit shortly as OKed by Paul on IRC.

Regression tested on x86-64-Gnu/Linux.

Regards,

Jerry

2007-07-28 Jerry DeLisle <jvdelisle@gcc.gnu.org>

	PR fortran/31609
	* resolve.c (generic_sym): Check for a same symbol and if so, return to
	avoid infinite recursion.


Index: resolve.c
===================================================================
--- resolve.c	(revision 126937)
+++ resolve.c	(working copy)
@@ -789,8 +789,16 @@ generic_sym (gfc_symbol *sym)
     return 0;
 
   gfc_find_symbol (sym->name, sym->ns->parent, 1, &s);
+  
+  if (s != NULL)
+    {
+      if (s == sym)
+	return 0;
+      else
+	return generic_sym (s);
+    }
 
-  return (s == NULL) ? 0 : generic_sym (s);
+  return 0;
 }
 
 
! { dg-do compile }
! PR31609 module that calls a contained function with an ENTRY point
! Test case derived from the PR

MODULE ksbin1_aux_mod
  CONTAINS
    SUBROUTINE sub
    i = k()
    END SUBROUTINE sub
    FUNCTION j () 
      print *, "in j"    
    j = 111 
    ENTRY k () 
      print *, "in k"    
    k = 222
    END FUNCTION j
END MODULE ksbin1_aux_mod

program testit
  use ksbin1_aux_mod
  l = j()
  print *, l
  l = k()
  print *, l
end program testit

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