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);
+    }
 }

Reply via email to