diff mbox

[2/2] PR debug/63240 Add DWARF representation for C++11 defaulted member function.

Message ID CAGyQ6gxREddH9Z5j4Q-E38HQegwY+Rc-wrEMWc1yNj-TE13yqQ@mail.gmail.com
State New
Headers show

Commit Message

Siva Chandra Oct. 3, 2014, 9:31 p.m. UTC
On Fri, Oct 3, 2014 at 12:00 PM, Mark Wielaard <mjw@redhat.com> wrote:
> Thanks for that reference. I was just stepping through gdb's
> gdbarch_return_in_first_hidden_param_p to understand why Siva's example
> did indeed seem to go wrong under GDB. That code is a little hairy with
> all the arch specific indirections, so I am happy I can stop now :)

I agree that GDB's code here is a spaghetti. The function
gdbarch_return_in_first_hidden_param_p seems like an arch related
function, but on most arch's it defaults to the language specific
function language_pass_by_reference via
default_return_in_first_hidden_param_p.

> I can adjust my patch so that it does mark the declaration with
> DW_AT_artificial if it is DECL_COPY_CONSTRUCTOR_P or DECL_DESTRUCTOR_P.
> But maybe that is probably better done as a separate patch.

I have been meaning to send a patch to mark members declared default
with DW_AT_artificial. I have attached what I had in mind with this
mail. If you think it is reasonable, I can send it formally in a
different thread.

> Or does it make sense to mark all defaulted special function members as
> artificial instead of having a separate attribute for it? The (small)
> advantage of having a separate attribute is that the consumer knows
> whether it was explicitly defaulted.

It might still be of value, may be to answer questions like "why is
the member marked as artificial?".

gcc/cp/ChangeLog:

2014-10-03  Siva Chandra Reddy  <sivachandra@google.com>

        * decl2.c (grokfield): Mark special methods declared as default
        to be artificial.

gcc/testsuite/ChangeLog:

2014-10-03  Siva Chandra Reddy  <sivachandra@google.com>

        * g++.dg/dwarf2/default-ctor-dtor.C: New test.

Comments

Jason Merrill Oct. 4, 2014, 6:13 p.m. UTC | #1
On 10/03/2014 05:31 PM, Siva Chandra wrote:
>          * decl2.c (grokfield): Mark special methods declared as default
>          to be artificial.

No, defaulted methods are still user-declared, not artificial.

Jason
diff mbox

Patch

diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 4be4847..6a9a047 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -957,6 +957,7 @@  grokfield (const cp_declarator *declarator,
 		  DECL_DEFAULTED_FN (value) = 1;
 		  DECL_INITIALIZED_IN_CLASS_P (value) = 1;
 		  DECL_DECLARED_INLINE_P (value) = 1;
+		  DECL_ARTIFICIAL (value) = 1;
 		}
 	    }
 	  else if (TREE_CODE (init) == DEFAULT_ARG)
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/default-ctor-dtor.C b/gcc/testsuite/g++.dg/debug/dwarf2/default-ctor-dtor.C
new file mode 100644
index 0000000..82c5e8d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/default-ctor-dtor.C
@@ -0,0 +1,22 @@ 
+// { dg-do compile }
+// { dg-options "-gdwarf-2 -dA -O0 -std=c++11 -fno-merge-debug-strings" }
+
+class A
+{
+public:
+  A () {}
+  A (const A &) = default;
+  ~A () = default;
+
+  int a;
+};
+
+int
+main ()
+{
+  A a;
+
+  return a.a;
+}
+
+// { dg-final { scan-assembler-times "DW_TAG_subprogram.*DW_AT_artificial.*DW_TAG_formal_parameter.*DW_TAG_formal_parameter.*DW_TAG_subprogram.*DW_AT_artificial.*DW_TAG_formal_parameter.*DW_TAG_formal_parameter" 1 } }