On Tue, Feb 09, 2021 at 02:40:12PM -0500, Jason Merrill wrote: > For GCC 11, I think let's fix the regression with your (Jakub) earlier > patch, maybe only for DIEs with DW_AT_const_value.
Thanks. Following works too, so I'll test it tonight. 2021-02-09 Jakub Jelinek <ja...@redhat.com> PR debug/98755 * dwarf2out.c (prune_unused_types_walk): Mark DW_TAG_variable DIEs at class scope for DWARF5+. --- gcc/dwarf2out.c.jj 2021-01-27 10:05:35.313942040 +0100 +++ gcc/dwarf2out.c 2021-02-09 20:51:42.907922550 +0100 @@ -29475,6 +29475,16 @@ prune_unused_types_walk (dw_die_ref die) if (die->die_perennial_p) break; + /* For static data members, the declaration in the class is supposed + to have DW_TAG_member tag in DWARF{3,4} but DW_TAG_variable in + DWARF5. DW_TAG_member will be marked, so mark even such + DW_TAG_variables in DWARF5, as long as it has DW_AT_const_value + attribute. */ + if (dwarf_version >= 5 + && class_scope_p (die->die_parent) + && get_AT (die, DW_AT_const_value)) + break; + /* premark_used_variables marks external variables --- don't mark them here. But function-local externals are always considered used. */ Jakub