===================================================================
@@ -0,0 +1,26 @@
+! { dg-do run }
+!
+! PR 46313: [OOP] class container naming collisions
+!
+! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
+
+module one
+ type two_three
+ end type
+end module
+
+module one_two
+ type three
+ end type
+end module
+
+use one
+use one_two
+class(two_three), allocatable :: a1
+class(three), allocatable :: a2
+
+if (same_type_as(a1,a2)) call abort()
+
+end
+
+! { dg-final { cleanup-modules "one one_two" } }
===================================================================
@@ -116,13 +116,16 @@ gfc_class_null_initializer (gfc_typespec *ts)
static void
get_unique_type_string (char *string, gfc_symbol *derived)
-{
+{
+ char dt_name[GFC_MAX_SYMBOL_LEN+1];
+ sprintf (dt_name, "%s", derived->name);
+ dt_name[0] = TOUPPER (dt_name[0]);
if (derived->module)
- sprintf (string, "%s_%s", derived->module, derived->name);
+ sprintf (string, "%s_%s", derived->module, dt_name);
else if (derived->ns->proc_name)
- sprintf (string, "%s_%s", derived->ns->proc_name->name, derived->name);
+ sprintf (string, "%s_%s", derived->ns->proc_name->name, dt_name);
else
- sprintf (string, "_%s", derived->name);
+ sprintf (string, "_%s", dt_name);
}