[PATCH] dwarf2out, v2: Fix up field_byte_offset [PR101378]

Jakub Jelinek jakub@redhat.com
Thu Nov 11 08:19:30 GMT 2021


Hi!

Bootstrapped/regtested now successfully on x86_64-linux and i686-linux,
verified the
struct S { int e; int a : 1, b : 7, c : 8, d : 16; } s;
struct T { int a : 1, b : 7; long long c : 8; int d : 16; } t;

int
main ()
{
  s.c = 0x55;
  s.d = 0xaaaa;
  t.c = 0x55;
  t.d = 0xaaaa;
  s.e++;
}
testcase is compiled the same way as before again, ok for trunk?

> 2021-11-10  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR debug/101378
> 	* dwarf2out.c (field_byte_offset): Do the PCC_BITFIELD_TYPE_MATTERS
> 	handling only for DECL_BIT_FIELD_TYPE decls.
> 
> 	* g++.dg/debug/dwarf2/pr101378.C: New test.
> 
> --- gcc/dwarf2out.c.jj	2021-11-05 10:19:46.339457342 +0100
> +++ gcc/dwarf2out.c	2021-11-09 15:01:51.425437717 +0100
> @@ -19646,6 +19646,7 @@ field_byte_offset (const_tree decl, stru
>       properly dynamic byte offsets only when PCC bitfield type doesn't
>       matter.  */
>    if (PCC_BITFIELD_TYPE_MATTERS
> +      && DECL_BIT_FIELD_TYPE (decl)
>        && TREE_CODE (DECL_FIELD_OFFSET (decl)) == INTEGER_CST)
>      {
>        offset_int object_offset_in_bits;
> --- gcc/testsuite/g++.dg/debug/dwarf2/pr101378.C.jj	2021-11-09 15:17:39.504975396 +0100
> +++ gcc/testsuite/g++.dg/debug/dwarf2/pr101378.C	2021-11-09 15:17:28.067137556 +0100
> @@ -0,0 +1,13 @@
> +// PR debug/101378
> +// { dg-do compile { target c++11 } }
> +// { dg-options "-gdwarf-5 -dA" }
> +// { dg-final { scan-assembler-times "0\[^0-9x\\r\\n\]* DW_AT_data_member_location" 1 } }
> +// { dg-final { scan-assembler-times "1\[^0-9x\\r\\n\]* DW_AT_data_member_location" 1 } }
> +// { dg-final { scan-assembler-times "2\[^0-9x\\r\\n\]* DW_AT_data_member_location" 1 } }
> +// { dg-final { scan-assembler-not "-1\[^0-9x\\r\\n\]* DW_AT_data_member_location" } }
> +
> +struct E {};
> +struct S
> +{
> +  [[no_unique_address]] E e, f, g;
> +} s;

	Jakub



More information about the Gcc-patches mailing list