From patchwork Wed Apr 11 17:48:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 151834 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 4A1ACB7083 for ; Thu, 12 Apr 2012 03:48:51 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1334771333; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=yG0nDCb TQFC4cQHyfsFm7fch3jE=; b=jcla5KhZg7sA0ET2ApqKWc7zA9lhqaIiFN9Lrfx QM2bf11S0RHYOy+NdACB88eOS3H9bsSholNzDeVfRf8EsiATmQiv44IBIcRgBD69 MJoJWE6ehjNebUO5iCMy27IO6rvDb6kZJk2UHR0xC/NKTyUaT7AROlCKkVHkB6jS mXJc= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=xWVxoYs8GxJd7plSAE7rai0aKoTC4dLq3eYSpLodbhGWHOF7OitBi9Twl/UXkZ XD8D4jVJ1cH639eEIsrkqYwuXMHIWF41gI6GGyJiTPU6RnOF05SNFPjwmiaBIQsV yGpJPJzu7s7IOmzfkWXYs6gMaMp/bsk4YhgshwStbfpP4=; Received: (qmail 17548 invoked by alias); 11 Apr 2012 17:48:35 -0000 Received: (qmail 17539 invoked by uid 22791); 11 Apr 2012 17:48:32 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, 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; Wed, 11 Apr 2012 17:48:16 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q3BHmF2n003324 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 11 Apr 2012 13:48:16 -0400 Received: from [10.3.113.125] (ovpn-113-125.phx2.redhat.com [10.3.113.125]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q3BHmFtJ002505; Wed, 11 Apr 2012 13:48:15 -0400 Message-ID: <4F85C3DF.5060705@redhat.com> Date: Wed, 11 Apr 2012 13:48:15 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 MIME-Version: 1.0 To: gcc-patches List , Dodji Seketeli Subject: C++ PATCH to c++/45088 (injected-class-name in dwarf output) 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 Dodji's final patch for 45088 fixed the GDB regression, but as Jakub recently pointed out to me, we still end up with redundant DW_TAG_pointer_types in some cases, with one for pointer-to-class and the other for pointer-to-injected-class-name. We strip the injected-class-name in dwarf2out so that both pointers point to the same target type. To avoid this, let's strip the injected-class-name earlier in the front end. Of course, this is what Dodji first proposed to do for this issue, and I steered him wrong... Tested x86_64-pc-linux-gnu, applying to trunk. commit 9a2db2e62c441147007f520a3983f6bc12a7385f Author: Jason Merrill Date: Wed Apr 11 11:05:28 2012 -0400 * decl.c (grokdeclarator): Strip the injected-class-name typedef if we are building a declaration or compound type. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 8b22192..711ceef 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8943,6 +8943,17 @@ grokdeclarator (const cp_declarator *declarator, error ("qualifiers are not allowed on declaration of %", ctor_return_type); + /* If we're using the injected-class-name to form a compound type or a + declaration, replace it with the underlying class so we don't get + redundant typedefs in the debug output. But if we are returning the + type unchanged, leave it alone so that it's available to + maybe_get_template_decl_from_type_decl. */ + if (CLASS_TYPE_P (type) + && DECL_SELF_REFERENCE_P (TYPE_NAME (type)) + && type == TREE_TYPE (TYPE_NAME (type)) + && (declarator || type_quals)) + type = DECL_ORIGINAL_TYPE (TYPE_NAME (type)); + type_quals |= cp_type_quals (type); type = cp_build_qualified_type_real (type, type_quals, ((typedef_decl && !DECL_ARTIFICIAL (typedef_decl) diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/self-ref-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/self-ref-1.C index 81bcb27..06db9dc 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/self-ref-1.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/self-ref-1.C @@ -5,7 +5,7 @@ struct A { - virtual ~A(); + virtual ~A(){} }; struct B : public A diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/self-ref-2.C b/gcc/testsuite/g++.dg/debug/dwarf2/self-ref-2.C index b1c5401..d5463c0 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/self-ref-2.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/self-ref-2.C @@ -6,7 +6,7 @@ template struct A { - virtual ~A(); + virtual ~A(){} }; struct B : public A