diff --git a/gcc/c-family/c-ada-spec.cc b/gcc/c-family/c-ada-spec.cc
index c9cf6237524cb42fc02319f28912b6e6ab364007..0c07bdf86fba467b705e1194e1d2e8c0985965b0 100644
--- a/gcc/c-family/c-ada-spec.cc
+++ b/gcc/c-family/c-ada-spec.cc
@@ -712,13 +712,20 @@ enum ada_name_role
   ADA_NAME_TEMPLATE_INSTANCE,
   ADA_NAME_AS_BASE,
   ADA_NAME_SYNTHETIC_FIELD,
-  ADA_NAME_FORMAL
+  ADA_NAME_FORMAL,
+  ADA_NAME_CLASS_PACKAGE,
+  ADA_NAME_CONSTRUCTOR,
+  ADA_NAME_DESTRUCTOR,
+  ADA_NAME_ASSIGNMENT
 };
 
 static const char *allocate_ada_name (const char *, tree, ada_name_role,
 				      tree, const char *, const char *);
 
 static void pp_ada_namespace_name (pretty_printer *, tree);
+static void reserve_ada_source_names (const char *);
+static bool method_name_matches_visible_type (tree, tree);
+static bool method_name_matches_destructor (tree);
 
 /* Return the innermost named C++ namespace containing NODE.  Anonymous
    namespaces do not add an Ada package level.  */
@@ -925,6 +932,9 @@ dump_ada_nodes (pretty_printer *pp, const char *source_file)
   /* Sort the table of declarations to dump by sloc.  */
   qsort (to_dump, to_dump_count, sizeof (tree), compare_node);
 
+  if (cpp_check)
+    reserve_ada_source_names (source_file);
+
   /* Fetch the table of comments.  */
   comments = cpp_get_comments (parse_in);
 
@@ -1691,6 +1701,88 @@ allocate_ada_name (const char *preferred, tree identity, ada_name_role role,
   return allocated->name;
 }
 
+/* Reserve DECL's spelling before any synthetic names are allocated.  This
+   gives user-written C++ identifiers priority independent of dump order.  */
+
+static void
+reserve_ada_source_decl (tree decl, const char *file)
+{
+  if (!decl || !DECL_P (decl))
+    return;
+
+  for (tree context = DECL_CONTEXT (decl); context; )
+    {
+      if (TREE_CODE (context) == NAMESPACE_DECL
+	  && DECL_NAME (context)
+	  && strcmp (IDENTIFIER_POINTER (DECL_NAME (context)), "::"))
+	{
+	  bool space_found = false;
+	  char *name = to_ada_name (IDENTIFIER_POINTER (DECL_NAME (context)),
+				    &space_found);
+	  allocate_ada_name (name, DECL_NAME (context), ADA_NAME_SOURCE,
+			     DECL_CONTEXT (context), file, "_Case_");
+	  free (name);
+	}
+
+      context = DECL_P (context) ? DECL_CONTEXT (context)
+		: TYPE_P (context) ? TYPE_CONTEXT (context) : NULL_TREE;
+    }
+
+  if (DECL_NAME (decl))
+    {
+      bool space_found = false;
+      char *name = to_ada_name (IDENTIFIER_POINTER (DECL_NAME (decl)),
+				&space_found);
+      allocate_ada_name (name, DECL_NAME (decl), ADA_NAME_SOURCE,
+			 DECL_CONTEXT (decl), file, "_Case_");
+      free (name);
+    }
+
+  if (TREE_CODE (decl) == FUNCTION_DECL)
+    for (tree arg = DECL_ARGUMENTS (decl); arg; arg = DECL_CHAIN (arg))
+      reserve_ada_source_decl (arg, file);
+}
+
+/* Reserve all source spellings in this generated Ada unit.  */
+
+static void
+reserve_ada_source_names (const char *file)
+{
+  for (int i = 0; i < to_dump_count; ++i)
+    {
+      tree decl = to_dump[i];
+      reserve_ada_source_decl (decl, file);
+      if (TREE_CODE (decl) == TYPE_DECL
+	  && RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl)))
+	for (tree field = TYPE_FIELDS (TREE_TYPE (decl)); field;
+	     field = TREE_CHAIN (field))
+	  reserve_ada_source_decl (field, file);
+    }
+}
+
+/* Return the allocated name of the package that encloses a non-trivial C++
+   class declaration.  */
+
+static const char *
+allocated_class_package_name (tree decl)
+{
+  bool space_found = false;
+  char *source = to_ada_name (IDENTIFIER_POINTER (DECL_NAME (decl)),
+			      &space_found);
+  const char *base
+    = allocate_ada_name (source, DECL_NAME (decl), ADA_NAME_SOURCE,
+			 DECL_CONTEXT (decl),
+			 LOCATION_FILE (decl_sloc (decl, false)), "_Case_");
+  char *candidate = concat ("Class_", base, NULL);
+  const char *allocated
+    = allocate_ada_name (candidate, TREE_TYPE (decl), ADA_NAME_CLASS_PACKAGE,
+			 DECL_CONTEXT (decl),
+			 LOCATION_FILE (decl_sloc (decl, false)), "_");
+  free (candidate);
+  free (source);
+  return allocated;
+}
+
 /* Dump in BUFFER the name of an identifier NODE of type TYPE, following Ada
    syntax.  LIMITED_ACCESS indicates whether NODE can be accessed through a
    limited 'with' clause rather than a regular 'with' clause.  */
@@ -1755,8 +1847,7 @@ pp_ada_tree_identifier (pretty_printer *buffer, tree node, tree type,
 	  && (external_decl
 	      || named_namespace_context (decl) != current_namespace))
 	{
-	  pp_string (buffer, "Class_");
-	  pp_string (buffer, allocated);
+	  pp_string (buffer, allocated_class_package_name (decl));
 	  pp_dot (buffer);
 	}
     }
@@ -2006,6 +2097,29 @@ parameter_name_conflicts_with_profile (tree parameter, tree func,
   return identifier_matches_type (name, return_type);
 }
 
+/* Return PARAMETER's complete Ada formal name.  A conflict with a profile
+   type is resolved before allocation, so a user-written the_Name remains a
+   distinct declaration rather than colliding with the generated spelling.  */
+
+static const char *
+allocated_formal_name (tree parameter, tree func, bool is_constructor)
+{
+  bool space_found = false;
+  char *base = to_ada_name (IDENTIFIER_POINTER (DECL_NAME (parameter)),
+			    &space_found);
+  const bool renamed
+    = parameter_name_conflicts_with_profile (parameter, func, is_constructor);
+  char *candidate = renamed ? concat ("the_", base, NULL) : xstrdup (base);
+  const char *allocated
+    = allocate_ada_name (candidate, renamed ? parameter : DECL_NAME (parameter),
+			 renamed ? ADA_NAME_FORMAL : ADA_NAME_SOURCE,
+			 DECL_CONTEXT (parameter),
+			 LOCATION_FILE (decl_sloc (func, false)), "_");
+  free (candidate);
+  free (base);
+  return allocated;
+}
+
 /* Dump in BUFFER a function declaration FUNC in Ada syntax.
    IS_METHOD indicates whether FUNC is a C++ method.
    IS_CONSTRUCTOR whether FUNC is a C++ constructor.
@@ -2083,11 +2197,8 @@ dump_ada_function_declaration (pretty_printer *buffer, tree func,
 	{
 	  if (DECL_NAME (arg))
 	    {
-	      if (parameter_name_conflicts_with_profile (arg, func,
-						  is_constructor))
-		pp_string (buffer, "the_");
-	      pp_ada_tree_identifier (buffer, DECL_NAME (arg), NULL_TREE,
-				      false);
+	      pp_string (buffer, allocated_formal_name (arg, func,
+						    is_constructor));
 	      pp_string (buffer, " : ");
 	    }
 	  else
@@ -2290,6 +2401,26 @@ dump_template_types (pretty_printer *buffer, tree types, int spc)
     }
 }
 
+/* Dump the allocated package name for a concrete template INSTANCE.  */
+
+static void
+dump_template_instance_name (pretty_printer *pp, tree tmpl, tree instance,
+			     tree types, int spc)
+{
+  pretty_printer name_pp;
+  const bool saved_package_prefix = package_prefix;
+  package_prefix = false;
+  dump_ada_node (&name_pp, instance, tmpl, spc, false, true);
+  dump_template_types (&name_pp, types, spc);
+  package_prefix = saved_package_prefix;
+  const char *candidate = pp_formatted_text (&name_pp);
+  const char *allocated
+    = allocate_ada_name (candidate, instance, ADA_NAME_TEMPLATE_INSTANCE,
+			 DECL_CONTEXT (tmpl),
+			 LOCATION_FILE (decl_sloc (tmpl, false)), "_");
+  pp_string (pp, allocated);
+}
+
 /* If NODE is a concrete template instance emitted in a nested package,
    dump the type name owned by that package.  */
 
@@ -2330,8 +2461,7 @@ dump_template_type_name (pretty_printer *buffer, tree node, int spc)
 	    continue;
 
 	  package_prefix = false;
-	  dump_ada_node (buffer, TYPE_NAME (instance), tmpl, spc, false, true);
-	  dump_template_types (buffer, types, spc);
+	  dump_template_instance_name (buffer, tmpl, instance, types, spc);
 	  pp_dot (buffer);
 	  dump_ada_node (buffer, TYPE_NAME (instance), tmpl, spc, false, true);
 	  package_prefix = true;
@@ -2387,8 +2517,7 @@ dump_ada_template (pretty_printer *buffer, tree t, int spc)
       INDENT (spc);
       pp_string (buffer, "package ");
       package_prefix = false;
-      dump_ada_node (buffer, instance, t, spc, false, true);
-      dump_template_types (buffer, types, spc);
+      dump_template_instance_name (buffer, t, instance, types, spc);
       pp_string (buffer, " is");
       spc += INDENT_INCR;
       newline_and_indent (buffer, spc);
@@ -2420,8 +2549,7 @@ dump_ada_template (pretty_printer *buffer, tree t, int spc)
       newline_and_indent (buffer, spc);
       pp_string (buffer, "use ");
       package_prefix = false;
-      dump_ada_node (buffer, instance, t, spc, false, true);
-      dump_template_types (buffer, types, spc);
+      dump_template_instance_name (buffer, t, instance, types, spc);
       package_prefix = true;
       current_template = previous_template;
       current_template_instance = previous_template_instance;
@@ -3284,15 +3412,69 @@ is_shortened_base_field (tree field)
        < (unsigned HOST_WIDE_INT) object_size * BITS_PER_UNIT;
 }
 
+/* Return the allocated name of NODE's shortened base-subobject type.  */
+
+static const char *
+allocated_as_base_name (tree node)
+{
+  tree decl = get_underlying_decl (node);
+  gcc_assert (decl && DECL_NAME (decl));
+  bool space_found = false;
+  char *source = to_ada_name (IDENTIFIER_POINTER (DECL_NAME (decl)),
+			      &space_found);
+  const char *base
+    = allocate_ada_name (source, DECL_NAME (decl), ADA_NAME_SOURCE,
+			 DECL_CONTEXT (decl),
+			 LOCATION_FILE (decl_sloc (decl, false)), "_Case_");
+  char *candidate = concat (base, "_As_Base", NULL);
+  const char *allocated
+    = allocate_ada_name (candidate, node, ADA_NAME_AS_BASE,
+			 DECL_CONTEXT (decl),
+			 LOCATION_FILE (decl_sloc (decl, false)), "_");
+  free (candidate);
+  free (source);
+  return allocated;
+}
+
+/* Dump NODE's shortened base-subobject type name.  */
+
+static void
+dump_ada_as_base_name (pretty_printer *buffer, tree node)
+{
+  pp_ada_namespace_prefix (buffer, get_underlying_decl (node));
+  pp_string (buffer, allocated_as_base_name (node));
+}
+
+/* Return the allocated name of an unnamed C++ base component.  NUMBER is its
+   one-based position among represented fields.  */
+
+static const char *
+allocated_synthetic_field_name (tree owner, tree field, int number)
+{
+  char candidate[32];
+  if (number == 1)
+    strcpy (candidate, "parent");
+  else
+    snprintf (candidate, sizeof (candidate), "field_%d", number);
+  tree decl = get_underlying_decl (owner);
+  gcc_assert (decl);
+  const char *allocated
+    = allocate_ada_name (candidate, field, ADA_NAME_SYNTHETIC_FIELD,
+			 owner, LOCATION_FILE (decl_sloc (decl, false)),
+			 "_Base_");
+  return allocated;
+}
+
 /* Dump FIELD's named type, selecting the shortened storage type when FIELD
    is a base subobject that excludes its type's virtual bases.  */
 
 static void
 dump_ada_record_field_type (pretty_printer *buffer, tree field)
 {
-  dump_ada_decl_name (buffer, TYPE_NAME (TREE_TYPE (field)), false);
   if (is_shortened_base_field (field))
-    pp_string (buffer, "_As_Base");
+    dump_ada_as_base_name (buffer, TREE_TYPE (field));
+  else
+    dump_ada_decl_name (buffer, TYPE_NAME (TREE_TYPE (field)), false);
 }
 
 /* Return true if FIELD lies wholly inside NODE's C++ as-base size.  */
@@ -3343,8 +3525,8 @@ dump_ada_as_base_storage_type (pretty_printer *buffer, tree node, tree type,
   pp_newline (buffer);
   newline_and_indent (buffer, spc);
   pp_string (buffer, "type ");
-  dump_ada_node (buffer, TYPE_NAME (node), type, spc, false, true);
-  pp_string (buffer, "_As_Base is record");
+  pp_string (buffer, allocated_as_base_name (node));
+  pp_string (buffer, " is record");
   pp_newline (buffer);
 
   for (tree field = TYPE_FIELDS (node); field; field = TREE_CHAIN (field))
@@ -3356,14 +3538,9 @@ dump_ada_as_base_storage_type (pretty_printer *buffer, tree node, tree type,
 	      continue;
 
 	    INDENT (spc + INDENT_INCR);
-	    if (field_num == 0)
-	      pp_string (buffer, "parent : ");
-	    else
-	      {
-		char buf[32];
-		sprintf (buf, "field_%d : ", field_num + 1);
-		pp_string (buffer, buf);
-	      }
+	    pp_string (buffer, allocated_synthetic_field_name (node, field,
+							       field_num + 1));
+	    pp_string (buffer, " : ");
 	    dump_ada_record_field_type (buffer, field);
 	    pp_semicolon (buffer);
 	    pp_newline (buffer);
@@ -3399,35 +3576,35 @@ dump_ada_as_base_storage_type (pretty_printer *buffer, tree node, tree type,
     {
       newline_and_indent (buffer, spc);
       pp_string (buffer, "pragma Component_Alignment (Storage_Unit, ");
-      dump_ada_node (buffer, TYPE_NAME (node), type, spc, false, true);
-      pp_string (buffer, "_As_Base);");
+      pp_string (buffer, allocated_as_base_name (node));
+      pp_string (buffer, ");");
     }
 
   newline_and_indent (buffer, spc);
   pp_string (buffer, "for ");
-  dump_ada_node (buffer, TYPE_NAME (node), type, spc, false, true);
-  pp_string (buffer, "_As_Base'Size use ");
+  pp_string (buffer, allocated_as_base_name (node));
+  pp_string (buffer, "'Size use ");
   pp_wide_integer (buffer, (HOST_WIDE_INT) data_size * BITS_PER_UNIT);
   pp_semicolon (buffer);
 
   newline_and_indent (buffer, spc);
   pp_string (buffer, "for ");
-  dump_ada_node (buffer, TYPE_NAME (node), type, spc, false, true);
-  pp_string (buffer, "_As_Base'Object_Size use ");
+  pp_string (buffer, allocated_as_base_name (node));
+  pp_string (buffer, "'Object_Size use ");
   pp_wide_integer (buffer, (HOST_WIDE_INT) data_size * BITS_PER_UNIT);
   pp_semicolon (buffer);
 
   newline_and_indent (buffer, spc);
   pp_string (buffer, "for ");
-  dump_ada_node (buffer, TYPE_NAME (node), type, spc, false, true);
-  pp_string (buffer, "_As_Base'Alignment use ");
+  pp_string (buffer, allocated_as_base_name (node));
+  pp_string (buffer, "'Alignment use ");
   pp_decimal_int (buffer, as_base_alignment (node, data_size));
   pp_semicolon (buffer);
 
   newline_and_indent (buffer, spc);
   pp_string (buffer, "for ");
-  dump_ada_node (buffer, TYPE_NAME (node), type, spc, false, true);
-  pp_string (buffer, "_As_Base use record");
+  pp_string (buffer, allocated_as_base_name (node));
+  pp_string (buffer, " use record");
 
   int repr_field_num = 0;
   for (tree field = TYPE_FIELDS (node); field; field = TREE_CHAIN (field))
@@ -3448,14 +3625,9 @@ dump_ada_as_base_storage_type (pretty_printer *buffer, tree node, tree type,
 	newline_and_indent (buffer, spc + INDENT_INCR);
 	if (DECL_NAME (field))
 	  dump_ada_decl_name (buffer, field, false);
-	else if (repr_field_num == 1)
-	  pp_string (buffer, "parent");
 	else
-	  {
-	    char buf[32];
-	    sprintf (buf, "field_%d", repr_field_num);
-	    pp_string (buffer, buf);
-	  }
+	  pp_string (buffer, allocated_synthetic_field_name (node, field,
+							 repr_field_num));
 	pp_string (buffer, " at ");
 	pp_unsigned_wide_integer (buffer, position);
 	pp_string (buffer, " range ");
@@ -3575,14 +3747,9 @@ dump_ada_cpp_layout (pretty_printer *buffer, tree node, tree type, int spc,
 	newline_and_indent (buffer, spc + INDENT_INCR);
 	if (DECL_NAME (field))
 	  dump_ada_decl_name (buffer, field, false);
-	else if (field_num == 1)
-	  pp_string (buffer, "parent");
 	else
-	  {
-	    char buf[32];
-	    sprintf (buf, "field_%d", field_num);
-	    pp_string (buffer, buf);
-	  }
+	  pp_string (buffer, allocated_synthetic_field_name (node, field,
+							 field_num));
 	pp_string (buffer, " at ");
 	pp_unsigned_wide_integer (buffer, position);
 	pp_string (buffer, " range ");
@@ -3856,10 +4023,20 @@ overloading_index (tree name)
 static void
 print_constructor (pretty_printer *buffer, tree t, tree type)
 {
-  tree decl_name = DECL_NAME (TYPE_NAME (type));
-
-  pp_string (buffer, "New_");
-  pp_ada_tree_identifier (buffer, decl_name, t, false);
+  tree type_decl = TYPE_NAME (type);
+  bool space_found = false;
+  char *source = to_ada_name (IDENTIFIER_POINTER (DECL_NAME (type_decl)),
+			      &space_found);
+  const char *base
+    = allocate_ada_name (source, DECL_NAME (type_decl), ADA_NAME_SOURCE,
+			 DECL_CONTEXT (type_decl),
+			 LOCATION_FILE (decl_sloc (type_decl, false)), "_Case_");
+  char *candidate = concat ("New_", base, NULL);
+  pp_string (buffer, allocate_ada_name (candidate, t, ADA_NAME_CONSTRUCTOR,
+					DECL_CONTEXT (t),
+					LOCATION_FILE (decl_sloc (t, false)), "_"));
+  free (candidate);
+  free (source);
 }
 
 /* Dump in BUFFER destructor spec corresponding to T.  */
@@ -3867,10 +4044,12 @@ print_constructor (pretty_printer *buffer, tree t, tree type)
 static void
 print_destructor (pretty_printer *buffer, tree t)
 {
-  if (startswith (IDENTIFIER_POINTER (DECL_NAME (t)), "__dt_del"))
-    pp_string (buffer, "Delete_And_Free");
-  else
-    pp_string (buffer, "Delete");
+  const char *candidate
+    = startswith (IDENTIFIER_POINTER (DECL_NAME (t)), "__dt_del")
+      ? "Delete_And_Free" : "Delete";
+  pp_string (buffer, allocate_ada_name (candidate, t, ADA_NAME_DESTRUCTOR,
+					DECL_CONTEXT (t),
+					LOCATION_FILE (decl_sloc (t, false)), "_"));
 }
 
 /* Dump in BUFFER assignment operator spec corresponding to T.  */
@@ -3878,31 +4057,68 @@ print_destructor (pretty_printer *buffer, tree t)
 static void
 print_assignment_operator (pretty_printer *buffer, tree t, tree type)
 {
-  tree decl_name = DECL_NAME (TYPE_NAME (type));
-
-  pp_string (buffer, "Assign_");
-  pp_ada_tree_identifier (buffer, decl_name, t, false);
-
-  if (cpp_check (t, GET_FUNCTION_QUALIFIERS)
-	& CPP_FUNCTION_MOVE_ASSIGNMENT)
-    pp_string (buffer, "_Move");
+  tree type_decl = TYPE_NAME (type);
+  bool space_found = false;
+  char *source = to_ada_name (IDENTIFIER_POINTER (DECL_NAME (type_decl)),
+			      &space_found);
+  const char *base
+    = allocate_ada_name (source, DECL_NAME (type_decl), ADA_NAME_SOURCE,
+			 DECL_CONTEXT (type_decl),
+			 LOCATION_FILE (decl_sloc (type_decl, false)), "_Case_");
+  char *candidate
+    = concat ("Assign_", base,
+	      (cpp_check (t, GET_FUNCTION_QUALIFIERS)
+	       & CPP_FUNCTION_MOVE_ASSIGNMENT) ? "_Move" : "", NULL);
+  pp_string (buffer, allocate_ada_name (candidate, t, ADA_NAME_ASSIGNMENT,
+					DECL_CONTEXT (t),
+					LOCATION_FILE (decl_sloc (t, false)), "_"));
+  free (candidate);
+  free (source);
 }
 
-/* Append the C++ method qualifiers that Ada profiles cannot represent.  */
+/* Return the complete Ada name of T, including distinctions Ada profiles
+   cannot express.  Allocate the complete name as one unit so it cannot
+   collide with a user-written identifier such as inspect_Const.  */
 
-static void
-print_method_qualifiers (pretty_printer *buffer, tree t)
+static const char *
+allocated_method_name (tree t, tree type, unsigned int overload_suffix)
 {
+  tree decl_name = DECL_NAME (t);
+  bool space_found = false;
+  char *base = to_ada_name (IDENTIFIER_POINTER (decl_name), &space_found);
   const int qualifiers = cpp_check (t, GET_FUNCTION_QUALIFIERS);
+  const bool renamed
+    = (method_name_matches_visible_type (decl_name, type)
+	|| method_name_matches_destructor (decl_name));
+  const size_t length = strlen (base) + 96;
+  char *candidate = XNEWVEC (char, length);
+  strcpy (candidate, base);
 
   if (qualifiers & CPP_FUNCTION_CONST)
-    pp_string (buffer, "_Const");
+    strcat (candidate, "_Const");
   if (qualifiers & CPP_FUNCTION_VOLATILE)
-    pp_string (buffer, "_Volatile");
+    strcat (candidate, "_Volatile");
   if (qualifiers & CPP_FUNCTION_LVALUE)
-    pp_string (buffer, "_Lvalue");
+    strcat (candidate, "_Lvalue");
   else if (qualifiers & CPP_FUNCTION_RVALUE)
-    pp_string (buffer, "_Rvalue");
+    strcat (candidate, "_Rvalue");
+  if (renamed)
+    strcat (candidate, "_Method");
+  if (overload_suffix > 1)
+    snprintf (candidate + strlen (candidate),
+	      length - strlen (candidate), "%u", overload_suffix);
+
+  const bool generated = qualifiers || renamed || overload_suffix > 1;
+  const char *allocated
+    = allocate_ada_name (candidate, generated ? t : decl_name,
+			 generated ? (renamed ? ADA_NAME_RENAMED_METHOD
+				      : ADA_NAME_QUALIFIED_METHOD)
+				   : ADA_NAME_SOURCE,
+			 DECL_CONTEXT (t),
+			 LOCATION_FILE (decl_sloc (t, false)), "_");
+  free (candidate);
+  free (base);
+  return allocated;
 }
 
 /* Return true if METHOD_NAME collides with the enclosing class or another
@@ -4101,8 +4317,8 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc)
                 if (separate_class_package (t))
 		  {
 		    is_class = true;
-		    pp_string (buffer, "package Class_");
-		    dump_ada_node (buffer, t, type, spc, false, true);
+		    pp_string (buffer, "package ");
+		    pp_string (buffer, allocated_class_package_name (t));
 		    pp_string (buffer, " is");
 		    spc += INDENT_INCR;
 		    newline_and_indent (buffer, spc);
@@ -4277,16 +4493,10 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc)
       else
 	{
 	  const unsigned int suffix = overloading_index (decl_name);
-	  pp_ada_tree_identifier (buffer, decl_name, t, false);
-	  if (is_method)
-	    {
-	      print_method_qualifiers (buffer, t);
-	      if (method_name_matches_visible_type (decl_name, type)
-		  || method_name_matches_destructor (decl_name))
-		pp_string (buffer, "_Method");
-	    }
-	  if (suffix > 1)
-	    pp_decimal_int (buffer, suffix);
+	  if (is_method || suffix > 1)
+	    pp_string (buffer, allocated_method_name (t, type, suffix));
+	  else
+	    pp_ada_tree_identifier (buffer, decl_name, t, false);
 	}
 
       dump_ada_function_declaration
@@ -4452,8 +4662,8 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc)
       newline_and_indent (buffer, spc);
       pp_string (buffer, "end;");
       newline_and_indent (buffer, spc);
-      pp_string (buffer, "use Class_");
-      dump_ada_node (buffer, t, type, spc, false, true);
+      pp_string (buffer, "use ");
+      pp_string (buffer, allocated_class_package_name (t));
       pp_semicolon (buffer);
       pp_newline (buffer);
 
@@ -4470,7 +4680,15 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc)
 
   else
     {
-      pp_string (buffer, ";  -- ");
+      const bool layout_terminated
+	= (TREE_CODE (t) == TYPE_DECL
+	   && RECORD_OR_UNION_TYPE_P (TREE_TYPE (t))
+	   && (needs_empty_class_layout (TREE_TYPE (t))
+	       || (((needs_tail_padding_layout (TREE_TYPE (t))
+		     || (cpp_check && cpp_check (TREE_TYPE (t), HAS_VIRTUAL_BASE))
+		     || has_concrete_nested_base (TREE_TYPE (t)))
+		    && has_constant_field_layout (TREE_TYPE (t))))));
+      pp_string (buffer, layout_terminated ? "  -- " : ";  -- ");
       dump_sloc (buffer, t);
 
       if (TREE_CODE (t) == TYPE_DECL
@@ -4543,13 +4761,9 @@ dump_ada_structure (pretty_printer *buffer, tree node, tree type, bool nested,
 		{
 		  INDENT (field_spc);
 
-		  if (field_num == 0)
-		    pp_string (buffer, "parent : aliased ");
-		  else
-		    {
-		      sprintf (buf, "field_%d : aliased ", field_num + 1);
-		      pp_string (buffer, buf);
-		    }
+		  pp_string (buffer, allocated_synthetic_field_name (node, tmp,
+								     field_num + 1));
+		  pp_string (buffer, " : aliased ");
 		  dump_ada_record_field_type (buffer, tmp);
 		  pp_semicolon (buffer);
 		}
diff --git a/gcc/testsuite/g++.dg/ada-spec/generated-name-identity.C b/gcc/testsuite/g++.dg/ada-spec/generated-name-identity.C
new file mode 100644
index 0000000000000000000000000000000000000000..5a866bead83d65e64904f21091f74cf860235d3c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ada-spec/generated-name-identity.C
@@ -0,0 +1,107 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-ada-spec-slim" } */
+/* { dg-final { scan-file generated_name_identity_c.ads "function inspect_Const_2" } } */
+/* { dg-final { scan-file generated_name_identity_c.ads "function inspect_Const " } } */
+/* { dg-final { scan-file generated_name_identity_c.ads "package Box_int_2 is" } } */
+/* { dg-final { scan-file generated_name_identity_c.ads "subtype Box_int is Box_int_2.Box" } } */
+/* { dg-final { scan-file generated_name_identity_c.ads "the_Widget_2 : int; the_Widget : int" } } */
+/* { dg-final { scan-file generated_name_identity_c.ads "type Tail_Derived_As_Base_2" } } */
+/* { dg-final { scan-file generated_name_identity_c.ads "parent_Base_2 : aliased Left" } } */
+/* { dg-final { scan-file generated_name_identity_c.ads "field_2_Base_2 : aliased Right" } } */
+/* { dg-final { scan-file generated_name_identity_c.ads "package Class_Gadget_2 is" } } */
+/* { dg-final { scan-file generated_name_identity_c.ads "function New_Creator_2" } } */
+/* { dg-final { scan-file generated_name_identity_c.ads "procedure Delete_2" } } */
+/* { dg-final { scan-file generated_name_identity_c.ads "function Assign_Assigner_2" } } */
+
+class Methods
+{
+public:
+  int inspect () const;
+  int inspect_Const ();
+};
+
+template<typename T>
+struct Box
+{
+  T value;
+};
+
+typedef Box<int> Box_int;
+
+struct Widget
+{
+  int value;
+};
+
+Widget *make_widget (int Widget, int the_Widget);
+
+struct Tail_Base
+{
+  char bytes[2];
+};
+
+struct Tail_Derived_As_Base
+{
+  int value;
+};
+
+struct alignas(2) Tail_Derived : Tail_Base
+{
+  char extra;
+};
+
+struct Left
+{
+  int left;
+};
+
+struct Right
+{
+  int right;
+};
+
+struct Both : Left, Right
+{
+  int parent;
+  int field_2;
+};
+
+struct Class_Gadget
+{
+  int value;
+};
+
+class Gadget
+{
+public:
+  int ping ();
+};
+
+class Creator
+{
+public:
+  Creator ();
+  int New_Creator ();
+};
+
+class Destroyer
+{
+public:
+  ~Destroyer ();
+  static int Delete;
+};
+
+class Assigner
+{
+public:
+  Assigner &operator= (const Assigner &);
+  int Assign_Assigner ();
+};
+
+extern "C" int
+generated_name_identity_oracle ()
+{
+  return 73;
+}
+
+/* { dg-final { cleanup-ada-spec } } */
