PR debug/63239 Add DWARF representation for C++11 deleted member function.
authorMark Wielaard <mjw@redhat.com>
Sun, 5 Oct 2014 15:25:03 +0000 (15:25 +0000)
committerMark Wielaard <mark@gcc.gnu.org>
Sun, 5 Oct 2014 15:25:03 +0000 (15:25 +0000)
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.

From-SVN: r215901

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/cp-objcp-common.c
gcc/cp/cp-objcp-common.h
gcc/dwarf2out.c
gcc/langhooks-def.h
gcc/langhooks.h
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/dwarf2/deleted-member-function.C [new file with mode: 0644]
include/ChangeLog
include/dwarf2.def

index 3bf6de1581c8c7b86f55bb45e0bf77d9c4a6a34d..25f4495fb3d0bfce0b6ec41d7d4e3550d5e68a8f 100644 (file)
@@ -1,3 +1,13 @@
+2014-10-02  Mark Wielaard  <mjw@redhat.com>
+
+       PR debug/63239
+       * 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.
+
 2014-10-04  Jan Hubicka  <hubicka@ucw.cz>
 
        * ipa-polymorphic-call.c (walk_ssa_copies): Recognize
index c0b6fb5d1f9fd58ded9e47a5c48d9fec1167fc2a..5cb8203a636f3986e747e8fb01571d1d79ac60d5 100644 (file)
@@ -1,3 +1,10 @@
+2014-10-02  Mark Wielaard  <mjw@redhat.com>
+
+       PR debug/63239
+       * 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.
+
 2014-10-03  Marc Glisse  <marc.glisse@inria.fr>
 
        PR c++/54427
index 0c50f4085ab54270a8eefac759d15980fba764f8..0d144ef0ba7105e881c3b2ef61655e5cca4c8c13 100644 (file)
@@ -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)
index 246800eef90d13a40c6d034dd0a28deaffbc923d..c289774b0c67dc7176a501b8fbab41c13dbc25a8 100644 (file)
@@ -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
index a64038c41a346f3a4c322f863c32f4c240d7222c..59c05edd893e9500fee65d0391361eb86c10ba96 100644 (file)
@@ -18306,6 +18306,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
index e77d2d9100e3bc6614e5e75e5d33a15ade5c35c0..e5ae3e3d6e8dfb0b47f50139094ab2171d8889b2 100644 (file)
@@ -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, \
index 72fa85ec0bb4e8819aab4edf73c2c33e1dbfebe6..32e76f99e524b31e41cca66147b42c8561645aac 100644 (file)
@@ -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);
index ce04eacf5c06ad635b104f5b293c638737be7991..b3921d61f308936b67787b1eb900685fdd4e5a68 100644 (file)
@@ -1,3 +1,8 @@
+2014-10-02  Mark Wielaard  <mjw@redhat.com>
+
+       PR debug/63239
+       * g++.dg/debug/dwarf2/deleted-member-function.C: New testcase.
+
 2014-10-04  Jan Hubicka  <hubicka@ucw.cz>
 
        * g++.dg/ipa/devirt-47.C: New testcase.
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 (file)
index 0000000..4cc77e6
--- /dev/null
@@ -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;
+}
index e282aed0494a16889c8b2ae25b25a6ef55db9e3b..fd6274fde1c1f46de8de8ef77dc54ea716b0f26c 100644 (file)
@@ -1,3 +1,8 @@
+2013-10-02  Mark Wielaard  <mjw@redhat.com>
+
+       PR debug/63239
+       * dwarf2.def (DW_AT_GNU_deleted): New attribute.
+
 2014-09-26  Max Ostapenko  <m.ostapenko@partner.samsung.com>
 
        * libiberty.h (PEX_STDOUT_APPEND): New flag.
index 71a37b30c9f87b429bab08a4a420caa9a6385503..42a8d4bceeb49c3e44efbbddf062b0780a722d65 100644 (file)
@@ -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)