@@ -15834,10 +15834,16 @@ add_AT_location_description (dw_die_ref
static void
add_accessibility_attribute (dw_die_ref die, tree decl)
{
+ /* In DW_TAG_class_type children DW_ACCESS_private is the default
+ instead of DW_ACCESS_public. Emit DW_ACCESS_private anyway
+ for compatibility. */
if (TREE_PROTECTED (decl))
add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_protected);
else if (TREE_PRIVATE (decl))
add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_private);
+ else if (die->die_parent
+ && die->die_parent->die_tag == DW_TAG_class_type)
+ add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_public);
}
/* Attach the specialized form of location attribute used for data members of
@@ -19567,10 +19573,15 @@ gen_inheritance_die (tree binfo, tree ac
if (BINFO_VIRTUAL_P (binfo))
add_AT_unsigned (die, DW_AT_virtuality, DW_VIRTUALITY_virtual);
+ /* DW_ACCESS_private is the default accessibility only in DW_TAG_class_type
+ children, but for compatibility emit DW_ACCESS_public here even
+ when it is the default. */
if (access == access_public_node)
add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_public);
else if (access == access_protected_node)
add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_protected);
+ else if (context_die->die_tag != DW_TAG_class_type)
+ add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_private);
}
/* Generate a DIE for a class member. */