While working on a patch to the Ada compiler, I found a spot in dwarf2out.cc that calls add_name_attribute where a call to add_name_and_src_coords_attributes would be better, because the latter respects DECL_NAMELESS.
gcc * dwarf2out.cc (modified_type_die): Call add_name_and_src_coords_attributes for type decls. --- gcc/dwarf2out.cc | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index 357efaa5990..9f6e7110411 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -14047,23 +14047,18 @@ modified_type_die (tree type, int cv_quals, bool reverse, Don't attach a DW_AT_name to DW_TAG_const_type or DW_TAG_volatile_type if the base type already has the same name. */ if (name - && ((TREE_CODE (name) != TYPE_DECL - && (qualified_type == TYPE_MAIN_VARIANT (type) - || (cv_quals == TYPE_UNQUALIFIED))) - || (TREE_CODE (name) == TYPE_DECL - && DECL_NAME (name) - && (TREE_TYPE (name) == qualified_type - || (lang_hooks.types.get_debug_type - && (lang_hooks.types.get_debug_type (TREE_TYPE (name)) - == qualified_type)))))) - { - if (TREE_CODE (name) == TYPE_DECL) - /* Could just call add_name_and_src_coords_attributes here, - but since this is a builtin type it doesn't have any - useful source coordinates anyway. */ - name = DECL_NAME (name); - add_name_attribute (mod_type_die, IDENTIFIER_POINTER (name)); - } + && TREE_CODE (name) != TYPE_DECL + && (qualified_type == TYPE_MAIN_VARIANT (type) + || (cv_quals == TYPE_UNQUALIFIED))) + add_name_attribute (mod_type_die, IDENTIFIER_POINTER (name)); + else if (name + && TREE_CODE (name) == TYPE_DECL + && DECL_NAME (name) + && (TREE_TYPE (name) == qualified_type + || (lang_hooks.types.get_debug_type + && (lang_hooks.types.get_debug_type (TREE_TYPE (name)) + == qualified_type)))) + add_name_and_src_coords_attributes (mod_type_die, name, true); else if (mod_type_die && mod_type_die->die_tag == DW_TAG_base_type) { if (TREE_CODE (type) == BITINT_TYPE) -- 2.45.0