On Thu, Oct 3, 2024 at 6:39 PM Tom Tromey <[email protected]> wrote:
>
> I am working on some changes to GNAT to emit hierarchical DWARF --
> i.e., where entities will have simple names nested in a DW_TAG_module.
>
> While working on this I found a couple of paths in modified_type_die
> where "mod_scope" should be used, but is not. I suspect these cases
> are only reachable by Ada code, as in both spots (subrange types and
> base types), I believe that other languages don't generally have named
> types in a non-top-level scope, and in these other situations,
> mod_scope will still be correct.
>
> gcc
>
> * dwarf2out.cc (modified_type_die): Use mod_scope for
> ranged types and base types.
>
> Issue: eng/toolchain/gcc#241
> ---
> gcc/dwarf2out.cc | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
> index 38aedb64470..67d2827c279 100644
> --- a/gcc/dwarf2out.cc
> +++ b/gcc/dwarf2out.cc
> @@ -13927,7 +13927,7 @@ modified_type_die (tree type, int cv_quals, bool
> reverse,
> tree bias = NULL_TREE;
> if (lang_hooks.types.get_type_bias)
> bias = lang_hooks.types.get_type_bias (type);
> - mod_type_die = subrange_type_die (type, low, high, bias, context_die);
> + mod_type_die = subrange_type_die (type, low, high, bias, mod_scope);
that looks good. But why not for the ARRAY_TYPE case dircetly above?
> item_type = TREE_TYPE (type);
> }
> else if (is_base_type (type))
> @@ -13964,10 +13964,10 @@ modified_type_die (tree type, int cv_quals, bool
> reverse,
> {
> dw_die_ref after_die
> = modified_type_die (type, cv_quals, false, context_die);
> - add_child_die_after (comp_unit_die (), mod_type_die, after_die);
> + add_child_die_after (mod_scope, mod_type_die, after_die);
For the next DW_AT_endianity there's an assert for the correct
placement but not here So I'm not
positive this change is according to the comment. In fact we're
realing with base-type DIEs here,
and those are usually directly at comp_unit_die (), no?
> }
> else
> - add_child_die (comp_unit_die (), mod_type_die);
> + add_child_die (mod_scope, mod_type_die);
>
> add_pubtype (type, mod_type_die);
> }
> --
> 2.46.2
>