c++: Mangling fix for type alias reflections [PR125680]

The following testcase ICEs, because we use write_unqualified_name to
write the type alias name.  Unfortunately, it is an alias for an unnamed
type and write_unqualified_name in that case uses
      if (TREE_CODE (decl) == TYPE_DECL
          && enum_with_enumerator_for_linkage_p (type))
        write_unnamed_enum_name (type);
      else if (TREE_CODE (decl) == TYPE_DECL && TYPE_UNNAMED_P (type))
        write_unnamed_type_name (type);
      else if (TREE_CODE (decl) == TYPE_DECL && LAMBDA_TYPE_P (type))
        write_closure_type_name (type);
      else
        write_source_name (DECL_NAME (decl));
and write_unnamed_type_node
  else if (TYPE_CLASS_SCOPE_P (type))
    discriminator = nested_anon_class_index (type);
and nested_anon_class_index ICEs, because type is the type alias and
obviously it can't find a type alias among DECL_IMPLICIT_TYPEDEF_P nembers.
In this case, we really want to write the source name of the type alias
(which always should have DECL_NAME), regardless of what the dealias
of the type alias is (that is emitted later in the mangling).

Note, this isn't the only PR against this area, there is another one where
write_prefix (decl_mangling_context (arg)); doesn't work properly for
local names.

2026-08-06  Jakub Jelinek  <jakub@redhat.com>

	PR c++/125680
	* mangle.cc (write_reflection): For type aliases use maybe_write_module
	and write_source_name instead of write_unqualified_name.

	* g++.dg/reflect/mangle8.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2 files changed