From patchwork Fri Oct 3 17:32:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Wielaard X-Patchwork-Id: 396361 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 12E38140174 for ; Sat, 4 Oct 2014 03:32:18 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:to:cc:date:in-reply-to:references :content-type:mime-version; q=dns; s=default; b=s/kAqaSWx8WegpSu p/CqUmTtLcn2vBmz6dWk1hBaWz3M0+9Yt2CE5Dg4xhu7m/xgK4IjD9uXrrdhNx6N /Vy5v63DRhbYIe+zRiUpAklMv6Ewz/1rCLuez8kYGRO8rchMQ/yFa8hWrrbwxXyt rT6p9JhS94Q1b0Rgbw84Sdo1mjg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:to:cc:date:in-reply-to:references :content-type:mime-version; s=default; bh=uLxigbTqloNO2IqCtF9ZmM LusVc=; b=fQ6xs3cg6C6PUAVpzW+TMH+9OHlLFoL7dhAgLCJKn6bHLH3OHu3q3Q 7+ltl4Q8x+E+JerW7cx0vx+WsD+eLRNzucUN0d+QNg+lvnxIGm6yC7VONCwk8LZB qLx7xleZCxex81nFcUSMu+yopceXtQIlbMGrjwpD2y1Vnp4axN1Gw= Received: (qmail 22176 invoked by alias); 3 Oct 2014 17:32:11 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 22166 invoked by uid 89); 3 Oct 2014 17:32:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 03 Oct 2014 17:32:09 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s93HW7T9025375 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 3 Oct 2014 13:32:08 -0400 Received: from bordewijk.wildebeest.org (ovpn-116-76.ams2.redhat.com [10.36.116.76]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s93HW60d010730 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 3 Oct 2014 13:32:07 -0400 Received: by bordewijk.wildebeest.org (Postfix, from userid 1000) id B29828143831; Fri, 3 Oct 2014 19:32:05 +0200 (CEST) Message-ID: <1412357525.5933.38.camel@bordewijk.wildebeest.org> Subject: Re: [PATCH 2/2] PR debug/63240 Add DWARF representation for C++11 defaulted member function. From: Mark Wielaard To: Jason Merrill Cc: gcc-patches@gcc.gnu.org, jwakely@redhat.com, dodji@redhat.com Date: Fri, 03 Oct 2014 19:32:05 +0200 In-Reply-To: <542EB895.2020705@redhat.com> References: <1412341922-7891-1-git-send-email-mjw@redhat.com> <1412341922-7891-2-git-send-email-mjw@redhat.com> <542EB00A.8040605@redhat.com> <1412346943.5933.36.camel@bordewijk.wildebeest.org> <542EB895.2020705@redhat.com> Mime-Version: 1.0 On Fri, 2014-10-03 at 10:54 -0400, Jason Merrill wrote: > "user-declared" includes declarations that are defaulted in the class > body. "user-provided" is the category that does not include such > declarations. O. Then I was indeed wrong and defaulted does not impact ABI at all. At least that is one worry less for the abi checkers :) In that case I think we should indeed not distinguish between DECL_DEFAULTED_IN_CLASS_P and DECL_DEFAULTED_OUTSIDE_CLASS_P and just use DECL_DEFAULTED_FN. Then the information provided is just that the source indicates that the special member function has the default implementation. Which still is useful to know for a consumer. If only to show the debug users what the intention of the original source code was. The following variant of the patch does that (and removes any mention of "out of class" definitions). Thanks, Mark From f72525e11d08ad49d208ab75c806326871d881d7 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 3 Oct 2014 14:44:27 +0200 Subject: [PATCH] PR debug/63240 Add DWARF representation for C++11 defaulted member function. gcc/ChangeLog * dwarf2out.c (gen_subprogram_die): When a member function is declared default then add a DW_AT_GNU_defaulted attribute. * langhooks.h (struct lang_hooks_for_decls): Add function_decl_defaulted_p langhook. * langhooks-def.h (LANG_HOOKS_FUNCTION_DECL_DEFAULTED_P): Define. (LANG_HOOKS_DECLS): Add LANG_HOOKS_FUNCTION_DECL_DEFAULTED_P. gcc/cp/ChangeLog * cp-objcp-common.h (LANG_HOOKS_FUNCTION_DECL_DEFAULTED_P): Define. (cp_function_decl_defaulted_p): New prototype. * cp-objcp-common.c (cp_function_defaulted_p): New function. gcc/testsuite/ChangeLog * g++.dg/debug/dwarf2/defaulted-member-function.C: New testcase. include/ChangeLog * dwarf2.def (DW_AT_GNU_defaulted): New attribute. --- gcc/ChangeLog | 10 ++++++++++ gcc/cp/ChangeLog | 7 +++++++ gcc/cp/cp-objcp-common.c | 10 ++++++++++ gcc/cp/cp-objcp-common.h | 3 +++ gcc/dwarf2out.c | 6 ++++++ gcc/langhooks-def.h | 2 ++ gcc/langhooks.h | 3 +++ gcc/testsuite/ChangeLog | 5 +++++ .../g++.dg/debug/dwarf2/defaulted-member-function.C | 17 +++++++++++++++++ include/ChangeLog | 5 +++++ include/dwarf2.def | 2 ++ 11 files changed, 70 insertions(+) create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/defaulted-member-function.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index dc3287b..255b1b6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2014-10-03 Mark Wielaard + + PR debug/63240 + * dwarf2out.c (gen_subprogram_die): When a member function is + declared default then add a DW_AT_GNU_defaulted attribute. + * langhooks.h (struct lang_hooks_for_decls): Add + function_decl_defaulted_p langhook. + * langhooks-def.h (LANG_HOOKS_FUNCTION_DECL_DEFAULTED_P): Define. + (LANG_HOOKS_DECLS): Add LANG_HOOKS_FUNCTION_DECL_DEFAULTED_P. + 2014-10-02 Mark Wielaard PR debug/63239 diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 921f95c..d88bcd8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2014-10-03 Mark Wielaard + + PR debug/63240 + * cp-objcp-common.h (LANG_HOOKS_FUNCTION_DECL_DEFAULTED_P): Define. + (cp_function_decl_defaulted_p): New prototype. + * cp-objcp-common.c (cp_function_defaulted_p): New function. + 2014-10-02 Mark Wielaard PR debug/63239 diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c index 0d144ef..e668183 100644 --- a/gcc/cp/cp-objcp-common.c +++ b/gcc/cp/cp-objcp-common.c @@ -178,6 +178,16 @@ cp_function_decl_deleted_p (tree decl) && DECL_DELETED_FN (decl)); } +/* Return true if DECL is defaulted special member function. */ + +bool +cp_function_decl_defaulted_p (tree decl) +{ + return (decl + && DECL_LANG_SPECIFIC (STRIP_TEMPLATE (decl)) + && DECL_DEFAULTED_FN (decl)); +} + /* Stubs to keep c-opts.c happy. */ void push_file_scope (void) diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h index c289774..348874f 100644 --- a/gcc/cp/cp-objcp-common.h +++ b/gcc/cp/cp-objcp-common.h @@ -28,6 +28,7 @@ extern tree objcp_tsubst_copy_and_build (tree, tree, tsubst_flags_t, extern bool cp_function_decl_explicit_p (tree decl); extern bool cp_function_decl_deleted_p (tree decl); +extern bool cp_function_decl_defaulted_p (tree decl); extern void cp_common_init_ts (void); /* Lang hooks that are shared between C++ and ObjC++ are defined here. Hooks @@ -134,6 +135,8 @@ extern void cp_common_init_ts (void); #define LANG_HOOKS_FUNCTION_DECL_EXPLICIT_P cp_function_decl_explicit_p #undef LANG_HOOKS_FUNCTION_DECL_DELETED_P #define LANG_HOOKS_FUNCTION_DECL_DELETED_P cp_function_decl_deleted_p +#undef LANG_HOOKS_FUNCTION_DECL_DEFAULTED_P +#define LANG_HOOKS_FUNCTION_DECL_DEFAULTED_P cp_function_decl_defaulted_p #undef LANG_HOOKS_OMP_PREDETERMINED_SHARING #define LANG_HOOKS_OMP_PREDETERMINED_SHARING cxx_omp_predetermined_sharing #undef LANG_HOOKS_OMP_CLAUSE_DEFAULT_CTOR diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 11544d8..54c2ee2 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -18305,6 +18305,12 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) && (! dwarf_strict)) add_AT_flag (subr_die, DW_AT_GNU_deleted, 1); + /* If this is a C++11 defaulted special function member then + generate a DW_AT_GNU_defaulted attribute. */ + if (lang_hooks.decls.function_decl_defaulted_p (decl) + && (! dwarf_strict)) + add_AT_flag (subr_die, DW_AT_GNU_defaulted, 1); + /* The first time we see a member function, it is in the context of the class to which it belongs. We make sure of this by emitting the class first. The next time is the definition, which is diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h index e5ae3e3..190a803 100644 --- a/gcc/langhooks-def.h +++ b/gcc/langhooks-def.h @@ -204,6 +204,7 @@ extern tree lhd_make_node (enum tree_code); #define LANG_HOOKS_GETDECLS getdecls #define LANG_HOOKS_FUNCTION_DECL_EXPLICIT_P hook_bool_tree_false #define LANG_HOOKS_FUNCTION_DECL_DELETED_P hook_bool_tree_false +#define LANG_HOOKS_FUNCTION_DECL_DEFAULTED_P hook_bool_tree_false #define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL lhd_warn_unused_global_decl #define LANG_HOOKS_WRITE_GLOBALS write_global_declarations #define LANG_HOOKS_DECL_OK_FOR_SIBCALL lhd_decl_ok_for_sibcall @@ -226,6 +227,7 @@ extern tree lhd_make_node (enum tree_code); LANG_HOOKS_GETDECLS, \ LANG_HOOKS_FUNCTION_DECL_EXPLICIT_P, \ LANG_HOOKS_FUNCTION_DECL_DELETED_P, \ + LANG_HOOKS_FUNCTION_DECL_DEFAULTED_P, \ LANG_HOOKS_GENERIC_GENERIC_PARAMETER_DECL_P, \ LANG_HOOKS_FUNCTION_PARM_EXPANDED_FROM_PACK_P, \ LANG_HOOKS_GET_GENERIC_FUNCTION_DECL, \ diff --git a/gcc/langhooks.h b/gcc/langhooks.h index 32e76f9..b1138a2 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -169,6 +169,9 @@ struct lang_hooks_for_decls /* Returns true if DECL is C++11 deleted special member function. */ bool (*function_decl_deleted_p) (tree); + /* Returns true if DECL is C++11 defaulted special member function. */ + bool (*function_decl_defaulted_p) (tree); + /* Returns True if the parameter is a generic parameter decl of a generic type, e.g a template template parameter for the C++ FE. */ bool (*generic_generic_parameter_decl_p) (const_tree); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2a6fe3f..353a90e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-10-03 Mark Wielaard + + PR debug/63240 + * g++.dg/debug/dwarf2/defaulted-member-function.C: New testcase. + 2014-10-02 Mark Wielaard PR debug/63239 diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/defaulted-member-function.C b/gcc/testsuite/g++.dg/debug/dwarf2/defaulted-member-function.C new file mode 100644 index 0000000..635e5ba --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/defaulted-member-function.C @@ -0,0 +1,17 @@ +// { dg-do compile } +// { dg-options "-O -std=c++11 -g -dA" } +// { dg-final { scan-assembler-times "# DW_AT_GNU_defaulted" 2 } } + +struct Foo +{ + Foo () {} + // Make copyable + Foo (const Foo&) = default; + Foo & operator=(const Foo&) = default; +}; + +void +bar () +{ + Foo foo; +} diff --git a/include/ChangeLog b/include/ChangeLog index fd6274f..e9a3a02 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,8 @@ +2013-10-03 Mark Wielaard + + PR debug/63240 + * dwarf2.def (DW_AT_GNU_defaulted): New attribute. + 2013-10-02 Mark Wielaard PR debug/63239 diff --git a/include/dwarf2.def b/include/dwarf2.def index 42a8d4b..067454c 100644 --- a/include/dwarf2.def +++ b/include/dwarf2.def @@ -385,6 +385,8 @@ DW_AT (DW_AT_GNU_all_source_call_sites, 0x2118) DW_AT (DW_AT_GNU_macros, 0x2119) /* Attribute for C++ deleted special member functions (= delete;). */ DW_AT (DW_AT_GNU_deleted, 0x211a) +/* Attribute for C++ defaulted function in class body (= default;). */ +DW_AT (DW_AT_GNU_defaulted, 0x211b) /* Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFission. */ DW_AT (DW_AT_GNU_dwo_name, 0x2130) DW_AT (DW_AT_GNU_dwo_id, 0x2131) -- 1.8.3.1