From patchwork Mon Sep 20 10:24:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 65195 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 5E0CCB70B8 for ; Mon, 20 Sep 2010 20:23:23 +1000 (EST) Received: (qmail 14378 invoked by alias); 20 Sep 2010 10:23:22 -0000 Received: (qmail 14369 invoked by uid 22791); 20 Sep 2010 10:23:21 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 20 Sep 2010 10:23:16 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8KANFE8023079 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 20 Sep 2010 06:23:15 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o8KANE45019036 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 20 Sep 2010 06:23:14 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o8KAOJXN005761; Mon, 20 Sep 2010 12:24:19 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o8KAOJWF005759; Mon, 20 Sep 2010 12:24:19 +0200 Date: Mon, 20 Sep 2010 12:24:19 +0200 From: Jakub Jelinek To: Jason Merrill Cc: Tom Tromey , gcc-patches@gcc.gnu.org, Roland McGrath Subject: Re: [PATCH] Fix up DW_AT_accessibility (PR debug/45124) Message-ID: <20100920102419.GI1269@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek References: <20100729130932.GF18378@tyan-ft48-01.lab.bos.redhat.com> <4C5189D4.5090203@redhat.com> <20100729171246.GJ18378@tyan-ft48-01.lab.bos.redhat.com> <4C51B6B5.4020400@redhat.com> <20100729202053.GO18378@tyan-ft48-01.lab.bos.redhat.com> <4C93759E.2010807@redhat.com> <20100917174412.GD1269@tyan-ft48-01.lab.bos.redhat.com> <4C93B0BC.6080004@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4C93B0BC.6080004@redhat.com> User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On Fri, Sep 17, 2010 at 02:17:32PM -0400, Jason Merrill wrote: > On 09/17/2010 01:44 PM, Jakub Jelinek wrote: > >So, should GCC assume for DWARF3+ that the default is always what the > >language (C++ in this case) says is the default (and adjust the standard)? > > Yes. Ok, so this patch implements that. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2010-09-20 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-09-19 18:55:48.663604621 +0200 +++ gcc/dwarf2out.c 2010-09-19 19:05:20.946228742 +0200 @@ -15832,10 +15832,22 @@ 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) + 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) + add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_public); } /* Attach the specialized form of location attribute used for data members of @@ -19552,10 +19564,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. */