From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 52986 invoked by alias); 13 Nov 2015 00:18:47 -0000 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 Received: (qmail 52962 invoked by uid 89); 13 Nov 2015 00:18:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL,BAYES_00,KAM_ASCII_DIVIDERS,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: troutmask.apl.washington.edu Received: from troutmask.apl.washington.edu (HELO troutmask.apl.washington.edu) (128.95.76.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 13 Nov 2015 00:18:46 +0000 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id tAD0IhAR050662 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 12 Nov 2015 16:18:44 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id tAD0IhRx050661; Thu, 12 Nov 2015 16:18:43 -0800 (PST) (envelope-from sgk) Date: Fri, 13 Nov 2015 00:18:00 -0000 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH,committed] PR fortran/68318 -- increment reference count Message-ID: <20151113001843.GA50627@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="1yeeQ81UyVL57Vl7" Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-SW-Source: 2015-11/txt/msg01617.txt.bz2 --1yeeQ81UyVL57Vl7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 804 I've committed the attached patch as obvious after testing on x86_64-*-freebsd. The short story is that gfortran tracks the number of ENTRY symbols with a reference count. If an ENTRY was included in a routine within a MODULE the reference count was not properly increment. This patch now does the increment. As a bonus it fixes a nearby comment that is missing a space, and changes the only occurence of ++sym->refs to sym->refs++ for consistency. 2015-11-12 Steven G. Kargl PR fortran/68318 * decl.c (get_proc_name): Increment reference count for ENTRY. While here, fix comment and use postfix ++ for consistency. 2015-11-12 Steven G. Kargl PR fortran/68318 * gfortran.dg/pr68318_1.f90: New test. * gfortran.dg/pr68318_2.f90: Ditto. -- Steve --1yeeQ81UyVL57Vl7 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pr68318.diff" Content-length: 2548 Index: gcc/fortran/decl.c =================================================================== --- gcc/fortran/decl.c (revision 230064) +++ gcc/fortran/decl.c (working copy) @@ -926,6 +926,7 @@ get_proc_name (const char *name, gfc_sym gfc_find_sym_tree (name, gfc_current_ns, 0, &st); st->n.sym = *result; st = gfc_get_unique_symtree (gfc_current_ns); + sym->refs++; st->n.sym = sym; } } @@ -972,7 +973,7 @@ get_proc_name (const char *name, gfc_sym /* Trap another encompassed procedure with the same name. All these conditions are necessary to avoid picking up an entry whose name clashes with that of the encompassing procedure; - this is handled using gsymbols to register unique,globally + this is handled using gsymbols to register unique, globally accessible names. */ if (sym->attr.flavor != 0 && sym->attr.proc != 0 @@ -9052,7 +9053,7 @@ gfc_match_final_decl (void) /* Add this symbol to the list of finalizers. */ gcc_assert (block->f2k_derived); - ++sym->refs; + sym->refs++; f = XCNEW (gfc_finalizer); f->proc_sym = sym; f->proc_tree = NULL; Index: gcc/testsuite/gfortran.dg/pr68318_1.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr68318_1.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr68318_1.f90 (working copy) @@ -0,0 +1,18 @@ +! { dg-do compile } +! { dg-options "-O0" +! PR fortran/68318 +! Original code submitted by Gerhard Steinmetz +! +! +module m + implicit none +contains + subroutine s1 + entry e ! { dg-error "(2)" } + end + subroutine s2 + entry e ! { dg-error "is already defined" } + end +end module +! { dg-prune-output "Duplicate ENTRY attribute specified" } + Index: gcc/testsuite/gfortran.dg/pr68318_2.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr68318_2.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr68318_2.f90 (working copy) @@ -0,0 +1,22 @@ +! { dg-do compile } +! PR fortran/68318 +! Original code submitted by Gerhard Steinmetz +! +! +module m1 + implicit none +contains + subroutine s1 + entry e + end +end module + +module m2 + use m1 ! { dg-error "(2)" } + implicit none +contains + subroutine s2 + entry e ! { dg-error "is already defined" } + end +end module +! { dg-prune-output "Cannot change attribute" } --1yeeQ81UyVL57Vl7--