dwarf2out: Don't prune static data members initialized with constants with -gdwarf-5 [PR98755]
In DWARF4 and earlier, static data members were represented as DW_TAG_member and the
pruning code wouldn't prune those, but in DWARF5 they are represented as DW_TAG_variable
with the class parent and the pruning code prunes those by default unless they are
referenced from a separate definition without the class parent (out of class definition).
C++17 inline vars have the definitions in the class though and even before if the static
data member isn't ODR used, it doesn't need to be defined, so we could just never describe
those static data members in the debug info.
This change stops the pruning of DW_TAG_variable with DW_AT_const_value attribute
with a class parent for -gdwarf-5 and later.
This fixes
-FAIL: g++.dg/debug/dwarf2/constexpr-var-1.C scan-assembler-times DW_AT_const_expr 2
-FAIL: libstdc++-prettyprinters/80276.cc whatis p4
-FAIL: libstdc++-prettyprinters/80276.cc whatis p4
-FAIL: libstdc++-prettyprinters/libfundts.cc print as
-FAIL: libstdc++-prettyprinters/libfundts.cc print as
-FAIL: libstdc++-prettyprinters/libfundts.cc print os
-FAIL: libstdc++-prettyprinters/libfundts.cc print os
2021-02-10 Jakub Jelinek <jakub@redhat.com>
PR debug/98755
* dwarf2out.c (prune_unused_types_walk): Mark DW_TAG_variable DIEs
at class scope for DWARF5+.