From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id 55D75385DC00 for ; Fri, 3 Apr 2020 22:47:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 55D75385DC00 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-18-CqtnHTINNUGTWGGP-TWp5w-1; Fri, 03 Apr 2020 18:47:17 -0400 X-MC-Unique: CqtnHTINNUGTWGGP-TWp5w-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 854E218C35A2 for ; Fri, 3 Apr 2020 22:47:16 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-113-52.ams2.redhat.com [10.36.113.52]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0E6AC60BF3; Fri, 3 Apr 2020 22:47:15 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id 033MlD86024963; Sat, 4 Apr 2020 00:47:14 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id 033MlDSn024962; Sat, 4 Apr 2020 00:47:13 +0200 Date: Sat, 4 Apr 2020 00:47:13 +0200 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] debug: Improve debug info of c++14 deduced return type [PR94459] Message-ID: <20200403224713.GK2212@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Spam-Status: No, score=-19.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Apr 2020 22:47:20 -0000 Hi! On the following testcase, in gdb ptype S::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. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2020-04-04 Domani Hannes =09 Jakub Jelinek =09PR debug/94459 =09* dwarf2out.c (gen_subprogram_die): Look through references, pointers =09and qualifiers when checking if in-class DIE had an 'auto' or =09'decltype(auto)' return type to emit type again on definition. =09* g++.dg/debug/pr94459.C: New test. --- gcc/dwarf2out.c.jj=092020-04-03 10:04:44.704972108 +0200 +++ gcc/dwarf2out.c=092020-04-03 17:52:48.909483818 +0200 @@ -22905,11 +22905,19 @@ gen_subprogram_die (tree decl, dw_die_re =09=09 !=3D (unsigned) s.column)) =09 add_AT_unsigned (subr_die, DW_AT_decl_column, s.column); =20 -=09 /* If the prototype had an 'auto' or 'decltype(auto)' return type, +=09 /* If the prototype had a cv 'auto' or 'decltype(auto)' return type, =09 emit the real type on the definition die. */ =09 if (is_cxx () && debug_info_level > DINFO_LEVEL_TERSE) =09 { =09 dw_die_ref die =3D get_AT_ref (old_die, DW_AT_type); +=09 while (die +=09=09 && (die->die_tag =3D=3D DW_TAG_reference_type +=09=09=09 || die->die_tag =3D=3D DW_TAG_rvalue_reference_type +=09=09=09 || die->die_tag =3D=3D DW_TAG_pointer_type +=09=09=09 || die->die_tag =3D=3D DW_TAG_const_type +=09=09=09 || die->die_tag =3D=3D DW_TAG_volatile_type +=09=09=09 || die->die_tag =3D=3D DW_TAG_restrict_type)) +=09=09die =3D get_AT_ref (die, DW_AT_type); =09 if (die =3D=3D auto_die || die =3D=3D decltype_auto_die) =09=09add_type_attribute (subr_die, TREE_TYPE (TREE_TYPE (decl)), =09=09=09=09 TYPE_UNQUALIFIED, false, context_die); --- gcc/testsuite/g++.dg/debug/pr94459.C.jj=092020-04-03 18:06:28.234725520= +0200 +++ gcc/testsuite/g++.dg/debug/pr94459.C=092020-04-03 18:05:59.287104932 +0= 200 @@ -0,0 +1,49 @@ +// PR debug/94459 +// { dg-do compile { target c++11 } } +// { dg-options "-g -dA" } + +template +struct S +{ + T v; + S () : v (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 +}; + +S s, u, v; + +long +foo () +{ + return s.m1 () + s.m2 () + s.m3 () + s.m4 () + s.m5 () +=09 + s.m6 () + s.m7 () + s.m8 () + s.m9 () + s.m10 () +=09 + s.m11 () + s.m12 () + s.m13 () + s.m14 () + s.m15 () +#ifndef __STRICT_ANSI__ +=09 + u.m16 () + v.m17 () +#endif +=09 + 0; +} + +int +main () +{ + return foo (); +} =09Jakub