Re: [PR63240] generate debug info for defaulted member functions

2016-08-08 Thread Jason Merrill
OK.

On Fri, Aug 5, 2016 at 5:47 PM, Alexandre Oliva  wrote:
> On Aug  4, 2016, Jason Merrill  wrote:
>
>> On Mon, Aug 1, 2016 at 10:57 PM, Alexandre Oliva  wrote:
>>> * langhooks.h (struct lang_hooks_for_decls): Add
>>> function_decl_defaulted_inclass_p and
>>> function_decl_defaulted_outofclass_p.
>
>> Maybe one hook that returns unsigned rather than two bool hooks?
>
> There's a suitable lhd that returns int, so I used that instead.  I
> noticed we should be using const_tree for these, so I adjusted them and,
> while at that, I adjusted _deleted and _explicit too.  Finally, having
> been informed of the constants for _defaulted and _deleted in DwARF v5
> drafts, I've dropped the _GNU attributes for these and started using the
> values from the draft, adjusting for them to be emitted even for strict
> DWARF v5.
>
> Here's what I'm testing.  Ok if it regstraps successfully?
>
>
>
>
> --
> Alexandre Oliva, freedom fighterhttp://FSFLA.org/~lxoliva/
> You must be the change you wish to see in the world. -- Gandhi
> Be Free! -- http://FSFLA.org/   FSF Latin America board member
> Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer
>


Re: [PR63240] generate debug info for defaulted member functions

2016-08-05 Thread Alexandre Oliva
On Aug  4, 2016, Jason Merrill <ja...@redhat.com> wrote:

> On Mon, Aug 1, 2016 at 10:57 PM, Alexandre Oliva <aol...@redhat.com> wrote:
>> * langhooks.h (struct lang_hooks_for_decls): Add
>> function_decl_defaulted_inclass_p and
>> function_decl_defaulted_outofclass_p.

> Maybe one hook that returns unsigned rather than two bool hooks?

There's a suitable lhd that returns int, so I used that instead.  I
noticed we should be using const_tree for these, so I adjusted them and,
while at that, I adjusted _deleted and _explicit too.  Finally, having
been informed of the constants for _defaulted and _deleted in DwARF v5
drafts, I've dropped the _GNU attributes for these and started using the
values from the draft, adjusting for them to be emitted even for strict
DWARF v5.

Here's what I'm testing.  Ok if it regstraps successfully?

[PR63240] generate debug info for defaulted member functions

From: Alexandre Oliva <aol...@redhat.com>

This implements <http://dwarfstd.org/ShowIssue.php?issue=141215.3>, a
proposal already accepted for inclusion in DWARF-5, but using
DW_AT_GNU_defaulted instead of DW_AT_defaulted as the attribute name,
because the attribute id for DW_AT_defaulted is not yet publicly
available.

for  include/ChangeLog

	PR debug/63240
	* dwarf2.def (DW_AT_deleted, DW_AT_defaulted): New.
	* dwarf2.h (enu dwarf_defaulted_attribute): New.

for  gcc/ChangeLog

	PR debug/63240
	* langhooks-def.h
	(LANG_HOOKS_FUNCTION_DECL_EXPLICIT_P): Const_tree-ify.
	(LANG_HOOKS_FUNCTION_DECL_DELETED_P): Likewise.
	(LANG_HOOKS_FUNCTION_DECL_DEFAULTED): Set default.
	(LANG_HOOKS_DECLS): Add it.
	* langhooks.h (struct lang_hooks_for_decls): Add
	function_decl_defaulted.  Const_tree-ify
	function_decl_explicit_p and function_decl_deleted_p.
	* dwarf2out.c (gen_subprogram_die): Add DW_AT_defaulted
	attribute.  Add DW_AT_deleted instead of DW_AT_GNU_deleted,
	also at strict DWARF v5.

for  gcc/cp/ChangeLog

	PR debug/63240
	* cp-objcp-common.c (cp_function_decl_defaulted): New.
	(cp_function_decl_explicit_p): Const_tree-ify.
	(cp_function_decl_deleted_p): Likewise.
	* cp-objcp-common.h (cp_function_decl_defaulted): Declare.
	(cp_function_decl_explicit_p): Const_tree-ify.
	(cp_function_decl_deleted_p): Likewise.
	(LANG_HOOKS_FUNCTION_DECL_DEFAULTED): Redefine.

for  gcc/testsuite/ChangeLog

	PR debug/63240
	* g++.dg/debug/dwarf2/defaulted-member-function-1.C: New.
	* g++.dg/debug/dwarf2/defaulted-member-function-2.C: New.
	* g++.dg/debug/dwarf2/defaulted-member-function-3.C: New.
	* g++.dg/debug/dwarf2/deleted-member-function.C: Expect
	DW_AT_deleted.
---
 gcc/cp/cp-objcp-common.c   |   25 +-
 gcc/cp/cp-objcp-common.h   |7 ++-
 gcc/dwarf2out.c|   49 +++-
 gcc/langhooks-def.h|6 ++
 gcc/langhooks.h|9 +++-
 .../debug/dwarf2/defaulted-member-function-1.C |   14 ++
 .../debug/dwarf2/defaulted-member-function-2.C |   16 +++
 .../debug/dwarf2/defaulted-member-function-3.C |   13 +
 .../g++.dg/debug/dwarf2/deleted-member-function.C  |2 -
 include/dwarf2.def |2 +
 include/dwarf2.h   |8 +++
 11 files changed, 139 insertions(+), 12 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/defaulted-member-function-1.C
 create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/defaulted-member-function-2.C
 create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/defaulted-member-function-3.C

diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c
index f7ddb00..9cb9dd7 100644
--- a/gcc/cp/cp-objcp-common.c
+++ b/gcc/cp/cp-objcp-common.c
@@ -133,7 +133,7 @@ cxx_types_compatible_p (tree x, tree y)
 /* Return true if DECL is explicit member function.  */
 
 bool
-cp_function_decl_explicit_p (tree decl)
+cp_function_decl_explicit_p (const_tree decl)
 {
   return (decl
 	  && DECL_LANG_SPECIFIC (STRIP_TEMPLATE (decl))
@@ -143,13 +143,34 @@ cp_function_decl_explicit_p (tree decl)
 /* Return true if DECL is deleted special member function.  */
 
 bool
-cp_function_decl_deleted_p (tree decl)
+cp_function_decl_deleted_p (const_tree decl)
 {
   return (decl
 	  && DECL_LANG_SPECIFIC (STRIP_TEMPLATE (decl))
 	  && DECL_DELETED_FN (decl));
 }
 
+/* Returns 0 if DECL is NOT a C++11 defaulted special member function,
+   1 if it is explicitly defaulted within the class body, or 2 if it
+   is explicitly defaulted outside the class body.  */
+
+int
+cp_function_decl_defaulted (const_tree decl)
+{
+  if (decl
+  && DECL_LANG_SPECIFIC (STRIP_TEMPLATE (decl))
+  && DECL_DEFAULTED_FN (decl))
+{
+  if (DECL_DEFAULTED_IN_CLASS_P (decl))
+	return 1;
+
+  if (DECL_DEFAULTED_OUTSIDE_CLASS_P (decl))
+	return 2;
+}
+
+  return 0;
+}
+
 /* Stubs to keep c-opt

Re: [PR63240] generate debug info for defaulted member functions

2016-08-04 Thread Jason Merrill
On Mon, Aug 1, 2016 at 10:57 PM, Alexandre Oliva  wrote:
> * langhooks.h (struct lang_hooks_for_decls): Add
> function_decl_defaulted_inclass_p and
> function_decl_defaulted_outofclass_p.

Maybe one hook that returns unsigned rather than two bool hooks?

Jason


[PR63240] generate debug info for defaulted member functions

2016-08-01 Thread Alexandre Oliva
This implements , a
proposal already accepted for inclusion in DWARF-5, but using
DW_AT_GNU_defaulted instead of DW_AT_defaulted as the attribute name,
because the attribute id for DW_AT_defaulted is not yet publicly
available.

Regstrapped on x86_64-linux-gnu and i686-linux-gnu.  Ok to install?

for  include/ChangeLog

PR debug/63240
* dwarf2.def (DW_AT_GNU_defaulted): New.
* dwarf2.h (enu dwarf_defaulted_attribute): New.

for  gcc/ChangeLog

PR debug/63240
* langhooks-def.h
(LANG_HOOKS_FUNCTION_DECL_DEFAULTED_INCLASS_P): Set default.
(LANG_HOOKS_FUNCTION_DECL_DEFAULTED_OUTOFCLASS_P): Likewise.
(LANG_HOOKS_DECLS): Add them.
* langhooks.h (struct lang_hooks_for_decls): Add
function_decl_defaulted_inclass_p and
function_decl_defaulted_outofclass_p.
* dwarf2out.c (gen_subprogram_die): Add DW_AT_GNU_defaulted
attribute.

for  gcc/cp/ChangeLog

PR debug/63240
* cp-objcp-common.c (cp_function_decl_defaulted_inclass_p,
cp_function_decl_defaulted_outofclass_p): New.
* cp-objcp-common.h (cp_function_decl_defaulted_inclass_p,
cp_function_decl_defaulted_outofclass_p): Declare.
(LANG_HOOKS_FUNCTION_DECL_DEFAULTED_INCLASS_P): Redefine.
(LANG_HOOKS_FUNCTION_DECL_DEFAULTED_OUTOFCLASS_P): Redefine.

for  gcc/testsuite/ChangeLog

PR debug/63240
* g++.dg/debug/dwarf2/defaulted-member-function-1.C: New.
* g++.dg/debug/dwarf2/defaulted-member-function-2.C: New.
* g++.dg/debug/dwarf2/defaulted-member-function-3.C: New.
---
 gcc/cp/cp-objcp-common.c   |   22 ++
 gcc/cp/cp-objcp-common.h   |8 +++
 gcc/dwarf2out.c|   24 
 gcc/langhooks-def.h|4 +++
 gcc/langhooks.h|8 +++
 .../debug/dwarf2/defaulted-member-function-1.C |   14 
 .../debug/dwarf2/defaulted-member-function-2.C |   16 +
 .../debug/dwarf2/defaulted-member-function-3.C |   13 +++
 include/dwarf2.def |2 ++
 include/dwarf2.h   |8 +++
 10 files changed, 119 insertions(+)
 create mode 100644 
gcc/testsuite/g++.dg/debug/dwarf2/defaulted-member-function-1.C
 create mode 100644 
gcc/testsuite/g++.dg/debug/dwarf2/defaulted-member-function-2.C
 create mode 100644 
gcc/testsuite/g++.dg/debug/dwarf2/defaulted-member-function-3.C

diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c
index f7ddb00..daa1b7e 100644
--- a/gcc/cp/cp-objcp-common.c
+++ b/gcc/cp/cp-objcp-common.c
@@ -150,6 +150,28 @@ cp_function_decl_deleted_p (tree decl)
  && DECL_DELETED_FN (decl));
 }
 
+/* Return true if DECL is a special member function defaulted within
+   the class body.  */
+
+bool
+cp_function_decl_defaulted_inclass_p (tree decl)
+{
+  return (decl
+ && DECL_LANG_SPECIFIC (STRIP_TEMPLATE (decl))
+ && DECL_DEFAULTED_IN_CLASS_P (decl));
+}
+
+/* Return true if DECL is a special member function defaulted outside
+   the class body.  */
+
+bool
+cp_function_decl_defaulted_outofclass_p (tree decl)
+{
+  return (decl
+ && DECL_LANG_SPECIFIC (STRIP_TEMPLATE (decl))
+ && DECL_DEFAULTED_OUTSIDE_CLASS_P (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 1bb19ee..7bba00d 100644
--- a/gcc/cp/cp-objcp-common.h
+++ b/gcc/cp/cp-objcp-common.h
@@ -28,6 +28,8 @@ 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_inclass_p (tree decl);
+extern bool cp_function_decl_defaulted_outofclass_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 +136,12 @@ 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_INCLASS_P
+#define LANG_HOOKS_FUNCTION_DECL_DEFAULTED_INCLASS_P \
+  cp_function_decl_defaulted_inclass_p
+#undef LANG_HOOKS_FUNCTION_DECL_DEFAULTED_OUTOFCLASS_P
+#define LANG_HOOKS_FUNCTION_DECL_DEFAULTED_OUTOFCLASS_P \
+  cp_function_decl_defaulted_outofclass_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 8d6eeed..71fa5ad 100644
--- a/gcc/dwarf2out.c
+++