From patchwork Fri Oct 3 13:12:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Wielaard X-Patchwork-Id: 396233 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 BD40B140139 for ; Fri, 3 Oct 2014 23:12:31 +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:from :to:cc:subject:date:message-id; q=dns; s=default; b=qb22WnUVfs2y ibrD9VcUb4Kez/lgJ3FeQt0PS8SPvL5VilFITajXau3hk6Nb30JkNS1xjFC8wUo4 wRrOEWN8q0/p8P0kvU6Csb2Jf37d6nVcbbhyXBZbyLVQCbFrbgENcLC7LXOVEW0L Uxih9Fi+0HfylqCXmanzUjs8oMuP8WY= 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:from :to:cc:subject:date:message-id; s=default; bh=fIbEdY2Vowq333qymC svfCVpH9o=; b=h66gfD9tuiXHsOnNPKfyujnHLa5y7Vd22JKHrqo0ly3Y+O35zS +puGAUxBzKVvnV+I48HTeWIeL1b5VJPh5O3G0YTAX1nyZPn7c4za/XLXsykvZ5Te zWNSqRRP/JTgfzDGaaDPVBX2NeseYGArSFQZSheDyMSPozdYxo/Be8VL0= Received: (qmail 22359 invoked by alias); 3 Oct 2014 13:12:24 -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 22344 invoked by uid 89); 3 Oct 2014 13:12:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 03 Oct 2014 13:12:21 +0000 From: Mark Wielaard To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, jwakely@redhat.com, dodji@redhat.com, Mark Wielaard Subject: [PATCH 1/2] PR debug/63239 Add DWARF representation for C++11 deleted member function. Date: Fri, 3 Oct 2014 15:12:01 +0200 Message-Id: <1412341922-7891-1-git-send-email-mjw@redhat.com> X-Spam-Score: -2.9 (--) Currently we output a declaration of the explicitly deleted function in DWARF. That seems wrong. An alternative to adding an attribute would be to just not output the declaration. But that is also confusing since then it looks precisely the same as an class that has that special function implicitly defined, since we don't output a declaration for such implicitly defined special functions either. So this implementation defines a new attribute DW_AT_GNU_deleted that gets added to the declaration. include/ChangeLog * dwarf2.def (DW_AT_GNU_deleted): New attribute. gcc/ChangeLog * dwarf2out.c (gen_subprogram_die): When a member function is explicitly deleted then add a DW_AT_GNU_deleted attribute. * langhooks.h (struct lang_hooks_for_decls): Add function_decl_deleted_p langhook. * langhooks-def.h (LANG_HOOKS_FUNCTION_DECL_DELETED_P): Define. (LANG_HOOKS_DECLS): Add LANG_HOOKS_FUNCTION_DECL_DELETED_P. gcc/cp/ChangeLog * cp-objcp-common.h (LANG_HOOKS_FUNCTION_DECL_DELETED_P): Define. (cp_function_decl_deleted_p): New prototype. * cp-objcp-common.c (cp_function_deleted_p): New function. gcc/testsuite/ChangeLog * g++.dg/debug/dwarf2/deleted-member-function.C: New testcase. --- 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/deleted-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/deleted-member-function.C diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c index 0c50f40..0d144ef 100644 --- a/gcc/cp/cp-objcp-common.c +++ b/gcc/cp/cp-objcp-common.c @@ -168,6 +168,16 @@ cp_function_decl_explicit_p (tree decl) && DECL_NONCONVERTING_P (decl)); } +/* Return true if DECL is deleted special member function. */ + +bool +cp_function_decl_deleted_p (tree decl) +{ + return (decl + && DECL_LANG_SPECIFIC (STRIP_TEMPLATE (decl)) + && DECL_DELETED_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 246800e..c289774 100644 --- a/gcc/cp/cp-objcp-common.h +++ b/gcc/cp/cp-objcp-common.h @@ -27,6 +27,7 @@ extern tree objcp_tsubst_copy_and_build (tree, tree, tsubst_flags_t, tree, bool); extern bool cp_function_decl_explicit_p (tree decl); +extern bool cp_function_decl_deleted_p (tree decl); extern void cp_common_init_ts (void); /* Lang hooks that are shared between C++ and ObjC++ are defined here. Hooks @@ -131,6 +132,8 @@ extern void cp_common_init_ts (void); #define LANG_HOOKS_GIMPLIFY_EXPR cp_gimplify_expr #undef LANG_HOOKS_FUNCTION_DECL_EXPLICIT_P #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_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 b5fcfa4..11544d8 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -18299,6 +18299,12 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) && (dwarf_version >= 3 || !dwarf_strict)) add_AT_flag (subr_die, DW_AT_explicit, 1); + /* If this is a C++11 deleted special function member then generate + a DW_AT_GNU_deleted attribute. */ + if (lang_hooks.decls.function_decl_deleted_p (decl) + && (! dwarf_strict)) + add_AT_flag (subr_die, DW_AT_GNU_deleted, 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 e77d2d9..e5ae3e3 100644 --- a/gcc/langhooks-def.h +++ b/gcc/langhooks-def.h @@ -203,6 +203,7 @@ extern tree lhd_make_node (enum tree_code); #define LANG_HOOKS_PUSHDECL pushdecl #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_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 @@ -224,6 +225,7 @@ extern tree lhd_make_node (enum tree_code); LANG_HOOKS_PUSHDECL, \ LANG_HOOKS_GETDECLS, \ LANG_HOOKS_FUNCTION_DECL_EXPLICIT_P, \ + LANG_HOOKS_FUNCTION_DECL_DELETED_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 72fa85e..32e76f9 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -166,6 +166,9 @@ struct lang_hooks_for_decls /* Returns true if DECL is explicit member function. */ bool (*function_decl_explicit_p) (tree); + /* Returns true if DECL is C++11 deleted special member function. */ + bool (*function_decl_deleted_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/g++.dg/debug/dwarf2/deleted-member-function.C b/gcc/testsuite/g++.dg/debug/dwarf2/deleted-member-function.C new file mode 100644 index 0000000..4cc77e6 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/deleted-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_deleted" 2 } } + +struct Foo +{ + Foo () {} + // Make non-copyable + Foo (const Foo&) = delete; + Foo & operator=(const Foo&) = delete; +}; + +void +bar () +{ + Foo foo; +} diff --git a/include/dwarf2.def b/include/dwarf2.def index 71a37b3..42a8d4b 100644 --- a/include/dwarf2.def +++ b/include/dwarf2.def @@ -383,6 +383,8 @@ DW_AT (DW_AT_GNU_all_call_sites, 0x2117) DW_AT (DW_AT_GNU_all_source_call_sites, 0x2118) /* Section offset into .debug_macro section. */ DW_AT (DW_AT_GNU_macros, 0x2119) +/* Attribute for C++ deleted special member functions (= delete;). */ +DW_AT (DW_AT_GNU_deleted, 0x211a) /* 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)