public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch, fortran] module that calls a contained function with an ENTRY  point
@ 2007-07-28 23:55 Jerry DeLisle
  0 siblings, 0 replies; only message in thread
From: Jerry DeLisle @ 2007-07-28 23:55 UTC (permalink / raw)
  To: Fortran List; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 474 bytes --]

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.



[-- Attachment #2: pr31609.diff --]
[-- Type: text/x-patch, Size: 444 bytes --]

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;
 }
 
 

[-- Attachment #3: entry_10.f90 --]
[-- Type: text/x-fortran, Size: 467 bytes --]

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-07-28 21:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-28 23:55 [patch, fortran] module that calls a contained function with an ENTRY point Jerry DeLisle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).