diff options
author | Jakub Jelinek <jakub@redhat.com> | 2020-04-05 00:28:28 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2020-04-05 00:31:12 +0200 |
commit | 0be9efad938726721fd8c8c35609b1e1d7d30035 (patch) | |
tree | 7b791fe73818013af433d080b69b69f83e61a844 /gcc/dwarf2out.c | |
parent | 458ca332d104240e7752eb1765660141fef878bd (diff) |
debug: Improve debug info of c++14 deduced return type [PR94459]
On the following testcase, in gdb ptype S<long>::m1 prints long as return
type, but all the other methods show void instead.
PR53756 added code to add_type_attribute if the return type is
auto/decltype(auto), but we actually should look through references,
pointers and qualifiers.
Haven't included there DW_TAG_atomic_type, because I think at least ATM
one can't use that in C++. Not sure about DW_TAG_array_type or what else
could be deduced.
> http://eel.is/c++draft/dcl.spec.auto#3 says it has to appear as a
> decl-specifier.
>
> http://eel.is/c++draft/temp.deduct.type#8 lists the forms where a template
> argument can be deduced.
>
> Looks like you are missing arrays, pointers to members, and function return
> types.
2020-04-04 Hannes Domani <ssbssa@yahoo.de>
Jakub Jelinek <jakub@redhat.com>
PR debug/94459
* dwarf2out.c (gen_subprogram_die): Look through references, pointers,
arrays, pointer-to-members, function types and qualifiers when
checking if in-class DIE had an 'auto' or 'decltype(auto)' return type
to emit type again on definition.
* g++.dg/debug/pr94459.C: New test.
Co-Authored-By: Hannes Domani <ssbssa@yahoo.de>
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r-- | gcc/dwarf2out.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index d68367eee3e..7d270f2a1b5 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -22905,11 +22905,22 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) != (unsigned) s.column)) add_AT_unsigned (subr_die, DW_AT_decl_column, s.column); - /* If the prototype had an 'auto' or 'decltype(auto)' return type, - emit the real type on the definition die. */ + /* If the prototype had an 'auto' or 'decltype(auto)' in + the return type, emit the real type on the definition die. */ if (is_cxx () && debug_info_level > DINFO_LEVEL_TERSE) { dw_die_ref die = get_AT_ref (old_die, DW_AT_type); + while (die + && (die->die_tag == DW_TAG_reference_type + || die->die_tag == DW_TAG_rvalue_reference_type + || die->die_tag == DW_TAG_pointer_type + || die->die_tag == DW_TAG_const_type + || die->die_tag == DW_TAG_volatile_type + || die->die_tag == DW_TAG_restrict_type + || die->die_tag == DW_TAG_array_type + || die->die_tag == DW_TAG_ptr_to_member_type + || die->die_tag == DW_TAG_subroutine_type)) + die = get_AT_ref (die, DW_AT_type); if (die == auto_die || die == decltype_auto_die) add_type_attribute (subr_die, TREE_TYPE (TREE_TYPE (decl)), TYPE_UNQUALIFIED, false, context_die); |