diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index fb0e3381e5b..e1d6a79ecd7 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -19646,6 +19646,7 @@ field_byte_offset (const_tree decl, struct vlr_context *ctx, 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; diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pr101378.C b/gcc/testsuite/g++.dg/debug/dwarf2/pr101378.C new file mode 100644 index 00000000000..ec5e44df804 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/pr101378.C @@ -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;