public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bernd Edlinger <bernd.edlinger@hotmail.de>
To: Tobias Burnus <burnus@net-b.de>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	"fortran@gcc.gnu.org"	<fortran@gcc.gnu.org>
Subject: [PATCH, FORTRAN]
Date: Tue, 08 Apr 2014 12:04:00 -0000	[thread overview]
Message-ID: <DUB129-W56C3370F2183FBCDC2EA1AE46B0@phx.gbl> (raw)

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

Hi,

this patch fixes a recently discovered name-clash in gfc_build_class_symbol.

Fortunately it is quite easy to fix: just make sure that the class names of target
classes end with "_t", and target array classes end with "[0-9]t".
This trick makes all names unique again.

I hope it is not too late, and this can still go into 4.9.0.

Boot-Strapped without any regressions on x86_64-unknown-linux-gnu.

Ok for trunk?

Thanks
Bernd.
 		 	   		  

[-- Attachment #2: changelog-class.txt --]
[-- Type: text/plain, Size: 299 bytes --]

gcc:
2014-04-08  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* fortran/class.c (gfc_build_class_symbol): Append "_t" to target class
	names to make the generated type names unique.

testsuite:
2014-04-08  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* gfortran.dg/class_nameclash.f90: New test.


[-- Attachment #3: patch-class.diff --]
[-- Type: application/octet-stream, Size: 1794 bytes --]

Index: gcc/fortran/class.c
===================================================================
--- gcc/fortran/class.c	(revision 209173)
+++ gcc/fortran/class.c	(working copy)
@@ -588,13 +588,13 @@ gfc_build_class_symbol (gfc_typespec *ts, symbol_a
   else if ((*as) && attr->pointer)
     sprintf (name, "__class_%s_%d_%dp", tname, rank, (*as)->corank);
   else if ((*as))
-    sprintf (name, "__class_%s_%d_%d", tname, rank, (*as)->corank);
+    sprintf (name, "__class_%s_%d_%dt", tname, rank, (*as)->corank);
   else if (attr->pointer)
     sprintf (name, "__class_%s_p", tname);
   else if (attr->allocatable)
     sprintf (name, "__class_%s_a", tname);
   else
-    sprintf (name, "__class_%s", tname);
+    sprintf (name, "__class_%s_t", tname);
 
   if (ts->u.derived->attr.unlimited_polymorphic)
     {
Index: gcc/testsuite/gfortran.dg/class_nameclash.f90
===================================================================
--- gcc/testsuite/gfortran.dg/class_nameclash.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/class_nameclash.f90	(revision 0)
@@ -0,0 +1,39 @@
+! { dg-do run }
+!
+! try to provoke class name clashes in gfc_build_class_symbol
+!
+module test_module
+
+  implicit none
+
+  type, public :: test_p
+    private
+    class (test_p), pointer :: next => null()
+  end type test_p
+
+  type, public :: test
+!   Error in "call do_it (x)" below:
+!   Type mismatch in argument 'x' at (1); passed CLASS(test_p) to CLASS(test)
+    class (test), pointer :: next => null()
+  end type test
+
+contains
+
+  subroutine do_it (x)
+    class (test_p), target :: x
+
+    x%next => x
+    return
+  end subroutine do_it
+
+end module test_module
+
+use test_module
+
+  implicit none
+  class (test_p), pointer :: x
+
+  allocate (x)
+  call do_it (x)
+  deallocate (x)
+end

             reply	other threads:[~2014-04-08 12:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-08 12:04 Bernd Edlinger [this message]
2014-04-08 12:10 ` FW: [PATCH, FORTRAN] Class Name Clash Bernd Edlinger
  -- strict thread matches above, loose matches on Subject: below --
2016-07-14 17:47 [patch, fortran] Jerry DeLisle
2014-09-08 21:23 [PATCH, Fortran] Alessandro Fanfarillo
     [not found] ` <540E2489.2030403@net-b.de>
2014-09-08 22:13   ` Alessandro Fanfarillo
2011-06-05 21:00 [patch, fortran] Thomas Koenig
2006-06-23 17:16 [Patch, fortran] Paul Thomas
2006-06-24 15:35 ` Steve Kargl
2006-06-25  7:09   ` Paul Thomas

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=DUB129-W56C3370F2183FBCDC2EA1AE46B0@phx.gbl \
    --to=bernd.edlinger@hotmail.de \
    --cc=burnus@net-b.de \
    --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).