public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/gccgo] debug: Improve debug info of c++14 deduced return type [PR94459]
@ 2020-04-07  1:34 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2020-04-07  1:34 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:0be9efad938726721fd8c8c35609b1e1d7d30035

commit 0be9efad938726721fd8c8c35609b1e1d7d30035
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sun Apr 5 00:28:28 2020 +0200

    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>

Diff:
---
 gcc/ChangeLog                        |  9 ++++++
 gcc/dwarf2out.c                      | 15 ++++++++--
 gcc/testsuite/ChangeLog              |  6 ++++
 gcc/testsuite/g++.dg/debug/pr94459.C | 58 ++++++++++++++++++++++++++++++++++++
 4 files changed, 86 insertions(+), 2 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 75e3a4f3993..9501c946cbd 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+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.
+
 2020-04-04  Jan Hubicka  <hubicka@ucw.cz>
 
 	PR ipa/93940
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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7b2d3c6edb1..058af2c3704 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2020-04-04  Hannes Domani  <ssbssa@yahoo.de>
+	    Jakub Jelinek  <jakub@redhat.com>
+
+	PR debug/94459
+	* g++.dg/debug/pr94459.C: New test.
+
 2020-04-04  Patrick Palka  <ppalka@redhat.com>
 
 	PR c++/94205
diff --git a/gcc/testsuite/g++.dg/debug/pr94459.C b/gcc/testsuite/g++.dg/debug/pr94459.C
new file mode 100644
index 00000000000..ebc0cf45cc6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/pr94459.C
@@ -0,0 +1,58 @@
+// PR debug/94459
+// { dg-do compile { target c++14 } }
+// { dg-options "-g -dA" }
+
+template <typename T>
+struct S
+{
+  T v;
+  T w[2];
+  S () : v (0), w { 0, 0 } {}
+  static auto baz () { return (T) 0; }
+  auto m1 () { return v; }
+  auto &m2 () { return v; }
+  auto &&m3 () { return (T&&)v; }
+  const auto m4 () { return v; }
+  const auto &m5 () { return v; }
+  const auto &&m6 () { return (T&&)v; }
+  volatile auto m7 () { return v; }
+  volatile auto &m8 () { return v; }
+  volatile auto &&m9 () { return (T&&)v; }
+  volatile const auto m10 () { return v; }
+  volatile const auto &m11 () { return v; }
+  volatile const auto &&m12 () { return (T&&)v; }
+  const volatile auto m13 () { return v; }
+  const volatile auto &m14 () { return v; }
+  const volatile auto &&m15 () { return (T&&)v; }
+#ifndef __STRICT_ANSI__
+  __restrict const volatile auto &&m16 () { return (T&&)v; }
+  const __restrict auto &m17 () { return v; }
+#endif
+  auto *m18 () { return &v; }
+  auto (S::* (m19 ())) () { return &S::m1; }
+  auto (S::* (m20 ())) { return &S::v; }
+  auto (*m21 ()) () { return S::baz; }
+};
+
+S<long> s, u, v;
+
+long
+foo ()
+{
+  auto x = s.m19 ();
+  auto y = s.m20 ();
+  auto z = s.m21 ();
+  return s.m1 () + s.m2 () + s.m3 () + s.m4 () + s.m5 ()
+	 + s.m6 () + s.m7 () + s.m8 () + s.m9 () + s.m10 ()
+	 + s.m11 () + s.m12 () + s.m13 () + s.m14 () + s.m15 ()
+#ifndef __STRICT_ANSI__
+	 + u.m16 () + v.m17 ()
+#endif
+	 + *s.m18 () + (s.*x) () + s.*y + z ();
+}
+
+int
+main ()
+{
+  return foo ();
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-04-07  1:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-07  1:34 [gcc/devel/gccgo] debug: Improve debug info of c++14 deduced return type [PR94459] Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).