From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22048 invoked by alias); 28 Jul 2007 21:14:05 -0000 Received: (qmail 22034 invoked by uid 22791); 28 Jul 2007 21:14:04 -0000 X-Spam-Check-By: sourceware.org Received: from vms040pub.verizon.net (HELO vms040pub.verizon.net) (206.46.252.40) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 28 Jul 2007 21:14:02 +0000 Received: from [192.168.1.2] ([71.120.231.21]) by vms040.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0JLW00MSMQZCZFGH@vms040.mailsrvcs.net>; Sat, 28 Jul 2007 16:14:01 -0500 (CDT) Date: Sat, 28 Jul 2007 23:55:00 -0000 From: Jerry DeLisle Subject: [patch, fortran] module that calls a contained function with an ENTRY point To: Fortran List Cc: gcc-patches Message-id: <46ABB0C3.90200@verizon.net> MIME-version: 1.0 Content-type: multipart/mixed; boundary=------------000600030107000409070207 User-Agent: Thunderbird 1.5.0.12 (X11/20070719) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2007-07/txt/msg02047.txt.bz2 This is a multi-part message in MIME format. --------------000600030107000409070207 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 474 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 PR fortran/31609 * resolve.c (generic_sym): Check for a same symbol and if so, return to avoid infinite recursion. --------------000600030107000409070207 Content-Type: text/x-patch; name="pr31609.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="pr31609.diff" Content-length: 444 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; } --------------000600030107000409070207 Content-Type: text/x-fortran; name="entry_10.f90" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="entry_10.f90" Content-length: 467 ! { 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 --------------000600030107000409070207--