This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/46313] [OOP] class container naming collisions
- From: "janus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 9 Nov 2010 16:32:19 +0000
- Subject: [Bug fortran/46313] [OOP] class container naming collisions
- Auto-submitted: auto-generated
- References: <bug-46313-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46313
--- Comment #9 from janus at gcc dot gnu.org 2010-11-09 16:32:16 UTC ---
(In reply to comment #7)
> Here is an example code which still fails (analogous to comment #0):
One way to fix this is to use the top-level namespace (i.e. program or module)
for the naming of the internal symbols, instead of the direct parent namespace
of the derived type (patch below).
Index: gcc/fortran/class.c
===================================================================
--- gcc/fortran/class.c (revision 166480)
+++ gcc/fortran/class.c (working copy)
@@ -117,7 +117,14 @@ get_unique_type_string (char *string, gfc_symbol *
if (derived->module)
sprintf (string, "%s_%s", derived->module, derived->name);
else
- sprintf (string, "%s_%s", derived->ns->proc_name->name, derived->name);
+ {
+ gfc_namespace *ns;
+ /* Find the top-level namespace (MODULE or PROGRAM). */
+ for (ns = derived->ns; ns; ns = ns->parent)
+ if (!ns->parent)
+ break;
+ sprintf (string, "%s_%s", ns->proc_name->name, derived->name);
+ }
}