diff mbox

[C++] RFC: implement P0386R2 - C++17 inline variables

Message ID 20161025180612.GA3541@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Oct. 25, 2016, 6:06 p.m. UTC
On Tue, Oct 25, 2016 at 04:05:30PM +0100, Andre Vieira (lists) wrote:
> I built gcc for the following:
> 1) revision r241135
> 2) revision r241135  + cherry-picked your patch in revision r241137
> (skipped the patch in revision r241136 because that gives a build failure).
> 3) trunk + patch in http://gcc.gnu.org/ml/gcc-patches/2016-10/msg01183.html
> 
> And compiling the member-ptr.cc file in the gdb testsuite without
> -std=c17 (see
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gdb/testsuite/gdb.cp/member-ptr.cc;h=4b7da34d3a77e3b5c045bd76d1f0a01514a039d7;hb=HEAD)
> leads to the following behavior:
> 
> 1) expected behavior, debug of information of objects of 'class A' looks
> fine.
> 2) new debug information for objects of 'class A' breaking the test.
> 3) same as 2)
> 
> As you can see the file has no explicit inline vars and I do not compile
> it with -std=c++17.
> 
> So I'm suspecting your patch changes this behavior in an unexpected way.

I think this patch should fix it, will bootstrap/regtest it now:

2016-10-25  Jakub Jelinek  <jakub@redhat.com>

	* dwarf2out.c (gen_member_die): Only reparent_child instead of
	splice_child_die if child doesn't have DW_AT_specification attribute.



	Jakub

Comments

Jakub Jelinek Oct. 25, 2016, 7:56 p.m. UTC | #1
On Tue, Oct 25, 2016 at 08:06:12PM +0200, Jakub Jelinek wrote:
> I think this patch should fix it, will bootstrap/regtest it now:
> 
> 2016-10-25  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* dwarf2out.c (gen_member_die): Only reparent_child instead of
> 	splice_child_die if child doesn't have DW_AT_specification attribute.

Bootstrapped/regtested on x86_64-linux and i686-linux now, with this
patch C++14 static data members are treated in debug info as they were in
the past, just C++17 static constexpr data mambers or other static inline
data members are treated the new way (definition in DW_TAG_member).

Ok for trunk?

> --- gcc/dwarf2out.c.jj	2016-10-25 19:49:28.000000000 +0200
> +++ gcc/dwarf2out.c	2016-10-25 20:02:33.264639847 +0200
> @@ -22624,7 +22624,8 @@ gen_member_die (tree type, dw_die_ref co
>  	  /* Handle inline static data members, which only have in-class
>  	     declarations.  */
>  	  if (child->die_tag == DW_TAG_variable
> -	      && child->die_parent == comp_unit_die ())
> +	      && child->die_parent == comp_unit_die ()
> +	      && get_AT (child, DW_AT_specification) == NULL)
>  	    {
>  	      reparent_child (child, context_die);
>  	      child->die_tag = DW_TAG_member;
> 

	Jakub
Yao Qi Oct. 26, 2016, 10:07 a.m. UTC | #2
On Tue, Oct 25, 2016 at 7:06 PM, Jakub Jelinek <jakub@redhat.com> wrote:
>
> I think this patch should fix it, will bootstrap/regtest it now:
>

Yes, the fails in gdb.cp/member-ptr.exp go away with the patched g++.
I run gdb.cp/member-ptr.exp with three different c++ variations,

Schedule of variations:
    unix/-std=c++03
    unix/-std=c++11
    unix/-std=c++1z

Thanks for the fix.
Jason Merrill Oct. 27, 2016, 1:55 p.m. UTC | #3
OK.

On Tue, Oct 25, 2016 at 3:56 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Tue, Oct 25, 2016 at 08:06:12PM +0200, Jakub Jelinek wrote:
>> I think this patch should fix it, will bootstrap/regtest it now:
>>
>> 2016-10-25  Jakub Jelinek  <jakub@redhat.com>
>>
>>       * dwarf2out.c (gen_member_die): Only reparent_child instead of
>>       splice_child_die if child doesn't have DW_AT_specification attribute.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux now, with this
> patch C++14 static data members are treated in debug info as they were in
> the past, just C++17 static constexpr data mambers or other static inline
> data members are treated the new way (definition in DW_TAG_member).
>
> Ok for trunk?
>
>> --- gcc/dwarf2out.c.jj        2016-10-25 19:49:28.000000000 +0200
>> +++ gcc/dwarf2out.c   2016-10-25 20:02:33.264639847 +0200
>> @@ -22624,7 +22624,8 @@ gen_member_die (tree type, dw_die_ref co
>>         /* Handle inline static data members, which only have in-class
>>            declarations.  */
>>         if (child->die_tag == DW_TAG_variable
>> -           && child->die_parent == comp_unit_die ())
>> +           && child->die_parent == comp_unit_die ()
>> +           && get_AT (child, DW_AT_specification) == NULL)
>>           {
>>             reparent_child (child, context_die);
>>             child->die_tag = DW_TAG_member;
>>
>
>         Jakub
diff mbox

Patch

--- gcc/dwarf2out.c.jj	2016-10-25 19:49:28.000000000 +0200
+++ gcc/dwarf2out.c	2016-10-25 20:02:33.264639847 +0200
@@ -22624,7 +22624,8 @@  gen_member_die (tree type, dw_die_ref co
 	  /* Handle inline static data members, which only have in-class
 	     declarations.  */
 	  if (child->die_tag == DW_TAG_variable
-	      && child->die_parent == comp_unit_die ())
+	      && child->die_parent == comp_unit_die ()
+	      && get_AT (child, DW_AT_specification) == NULL)
 	    {
 	      reparent_child (child, context_die);
 	      child->die_tag = DW_TAG_member;