public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Steve Kargl <sgk@troutmask.apl.washington.edu>
To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [PATCH,committed] PR fortran/68318 -- increment reference count
Date: Fri, 13 Nov 2015 00:18:00 -0000	[thread overview]
Message-ID: <20151113001843.GA50627@troutmask.apl.washington.edu> (raw)

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

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  <kargl@gcc.gnu.org>

	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  <kargl@gcc.gnu.org>

	PR fortran/68318
	* gfortran.dg/pr68318_1.f90: New test.
	* gfortran.dg/pr68318_2.f90: Ditto.

-- 
Steve

[-- Attachment #2: pr68318.diff --]
[-- Type: text/x-diff, Size: 2548 bytes --]

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
+! <gerhard dot steinmetz dot fortran at t-online dot de>
+!
+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
+! <gerhard dot steinmetz dot fortran at t-online dot de>
+!
+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" }

                 reply	other threads:[~2015-11-13  0:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151113001843.GA50627@troutmask.apl.washington.edu \
    --to=sgk@troutmask.apl.washington.edu \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).