From patchwork Thu Jul 29 20:20:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Fix up DW_AT_accessibility (PR debug/45124) Date: Thu, 29 Jul 2010 10:20:53 -0000 From: Jakub Jelinek X-Patchwork-Id: 60312 Message-Id: <20100729202053.GO18378@tyan-ft48-01.lab.bos.redhat.com> To: Jason Merrill Cc: Tom Tromey , gcc-patches@gcc.gnu.org, Roland McGrath On Thu, Jul 29, 2010 at 01:13:25PM -0400, Jason Merrill wrote: > OK. Actually, given the response on Dwarf-Discuss, I believe we should limit this only to DW_TAG_member and DW_TAG_subprogram (to match the spec; DW_TAG_inheritance handled in the other routine), as for say types and other children of DW_TAG_class_type no DECL_PRIVATE doesn't mean we need to emit DW_AT_accessibility DW_ACCESS_public, but instead just that accessibility is not meaningful for it. 2010-07-29 Jakub Jelinek PR debug/45124 * dwarf2out.c (add_accessibility_attribute): Assume DW_ACCESS_private as the default for dwarf_version > 2 and DW_TAG_class_type parent. (gen_inheritance_die): Assume DW_ACCESS_public as the default for dwarf_version > 2 and parent other than DW_TAG_class_type. Jakub --- gcc/dwarf2out.c.jj 2010-07-29 21:49:03.827604473 +0200 +++ gcc/dwarf2out.c 2010-07-29 22:14:28.231354703 +0200 @@ -15834,10 +15834,26 @@ add_AT_location_description (dw_die_ref static void add_accessibility_attribute (dw_die_ref die, tree decl) { + /* In DWARF3+ the default is DW_ACCESS_private only in DW_TAG_class_type + children, otherwise the default is DW_ACCESS_public. In DWARF2 + the default has always been DW_ACCESS_public. */ 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); + { + if (dwarf_version == 2 + || die->die_parent == NULL + || die->die_parent->die_tag != DW_TAG_class_type + || (die->die_tag != DW_TAG_member + && die->die_tag != DW_TAG_subprogram)) + add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_private); + } + else if (dwarf_version > 2 + && die->die_parent + && die->die_parent->die_tag == DW_TAG_class_type + && (die->die_tag == DW_TAG_member + || die->die_tag == DW_TAG_subprogram)) + add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_public); } /* Attach the specialized form of location attribute used for data members of @@ -19567,10 +19583,20 @@ gen_inheritance_die (tree binfo, tree ac if (BINFO_VIRTUAL_P (binfo)) add_AT_unsigned (die, DW_AT_virtuality, DW_VIRTUALITY_virtual); + /* In DWARF3+ the default is DW_ACCESS_private only in DW_TAG_class_type + children, otherwise the default is DW_ACCESS_public. In DWARF2 + the default has always been DW_ACCESS_private. */ if (access == access_public_node) - add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_public); + { + if (dwarf_version == 2 + || context_die->die_tag == DW_TAG_class_type) + 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 (dwarf_version > 2 + && 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. */