From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28956 invoked by alias); 28 Jun 2014 23:27:00 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 28918 invoked by uid 89); 28 Jun 2014 23:26:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sat, 28 Jun 2014 23:26:53 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id B5E0A541D60; Sun, 29 Jun 2014 01:26:50 +0200 (CEST) Date: Sat, 28 Jun 2014 23:27:00 -0000 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, jason@redhat.com Subject: [C++] Avoid producing duplicate binfos for member pointers Message-ID: <20140628232650.GB6942@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2014-06/txt/msg02320.txt.bz2 Jason, this is another case cought by the type variant checking. build_ptrmemfunc_type, for qualified type, first calls itself recursively to produce member pointer type for unqalified variant. Subsequentely it produces the member pointer from scratch - I believe it is because the field decl representing pointer should be qualified, so we have rather rare case where we do not share fields in between type and variant (other is Fortran when dropping restrict quantifiers deeply from the structure). It however produces fresh BINFO for the variant and overwrites its BINFO_TYPE pointer to t. I do not see a reason for having duplicated binfo here: both structures should be equivalent from type inheritance POV. This patch just avoids the duplicated BINFO and copies one from unqalified variant, if available. Seems sane? Bootstrapped/regtested x86_64-linux. * decl.c (build_ptrmemfunc_type): Do not produce duplicated BINFO for the variant. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 212098) +++ cp/decl.c (working copy) @@ -8074,7 +8074,6 @@ build_ptrmemfunc_type (tree type) = build_ptrmemfunc_type (TYPE_MAIN_VARIANT (type)); t = make_class_type (RECORD_TYPE); - xref_basetypes (t, NULL_TREE); /* Let the front end know this is a pointer to member function... */ TYPE_PTRMEMFUNC_FLAG (t) = 1; @@ -8109,8 +8108,10 @@ build_ptrmemfunc_type (tree type) TYPE_MAIN_VARIANT (t) = unqualified_variant; TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (unqualified_variant); TYPE_NEXT_VARIANT (unqualified_variant) = t; - TREE_TYPE (TYPE_BINFO (t)) = t; + TYPE_BINFO (t) = TYPE_BINFO (unqualified_variant); } + else + xref_basetypes (t, NULL_TREE); /* Cache this pointer-to-member type so that we can find it again later. */