for (member = TYPE_FIELDS (type); member; member = DECL_CHAIN (member))
{
struct vlr_context vlr_ctx = { type, NULL_TREE };
+ bool static_inline_p
+ = (TREE_STATIC (member)
+ && (lang_hooks.decls.decl_dwarf_attribute (member, DW_AT_inline)
+ != -1));
/* If we thought we were generating minimal debug info for TYPE
and then changed our minds, some of the member declarations
{
/* Handle inline static data members, which only have in-class
declarations. */
+ dw_die_ref ref = NULL;
+ if (child->die_tag == DW_TAG_variable
+ && child->die_parent == comp_unit_die ())
+ {
+ ref = get_AT_ref (child, DW_AT_specification);
+ /* For C++17 inline static data members followed by redundant
+ out of class redeclaration, we might get here with
+ child being the DIE created for the out of class
+ redeclaration and with its DW_AT_specification being
+ the DIE created for in-class definition. We want to
+ reparent the latter, and don't want to create another
+ DIE with DW_AT_specification in that case, because
+ we already have one. */
+ if (ref
+ && static_inline_p
+ && ref->die_tag == DW_TAG_variable
+ && ref->die_parent == comp_unit_die ()
+ && get_AT (ref, DW_AT_specification) == NULL)
+ {
+ child = ref;
+ ref = NULL;
+ static_inline_p = false;
+ }
+ }
if (child->die_tag == DW_TAG_variable
&& child->die_parent == comp_unit_die ()
- && get_AT (child, DW_AT_specification) == NULL)
+ && ref == NULL)
{
reparent_child (child, context_die);
if (dwarf_version < 5)
/* For C++ inline static data members emit immediately a DW_TAG_variable
DIE that will refer to that DW_TAG_member/DW_TAG_variable through
DW_AT_specification. */
- if (TREE_STATIC (member)
- && (lang_hooks.decls.decl_dwarf_attribute (member, DW_AT_inline)
- != -1))
+ if (static_inline_p)
{
int old_extern = DECL_EXTERNAL (member);
DECL_EXTERNAL (member) = 0;