From patchwork Thu Dec 6 22:14:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 204328 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 499BA2C00D6 for ; Fri, 7 Dec 2012 09:14:18 +1100 (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=1355436859; 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=m08++ly LkNtG8ljpUgWNPm0QGC4=; b=srzdzfBpWTmqufNR+5/0rqAbxrSYjAO90eGkA8K vH/hDMIdX89eg1lycnqANJfraZRiYTlm00+0H8WgWX8IA2VaxdsxDx51W2Bea4R9 xdbqSy9d6zIgIdn/psgb7p7Ct6kzhRgxfe5cJObO9MsX11i82aDvhSvJQhZfSkIU m9m0= 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=mzASfadaL+DiSP4OpjrDwLtW7VBOMU4w11eyQPrzmNcY7Sp7UVWAsih9p9/Xo3 EFkwWHBsyOkHGcQmGsn5VZ8eq9IYdxmiyFzf5jr80mrURed2cwRrbK592lOjsyuo zVjX2bSt7Qg8LLBpFlRfvfWmS3Lc/NYbLLNW/Wd/oUtAA=; Received: (qmail 11882 invoked by alias); 6 Dec 2012 22:14:15 -0000 Received: (qmail 11871 invoked by uid 22791); 6 Dec 2012 22:14:14 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS 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; Thu, 06 Dec 2012 22:14:08 +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 qB6ME7Lu015382 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 6 Dec 2012 17:14:07 -0500 Received: from [10.3.113.19] ([10.3.113.19]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qB6ME6AT011810 for ; Thu, 6 Dec 2012 17:14:07 -0500 Message-ID: <50C118AE.2060204@redhat.com> Date: Thu, 06 Dec 2012 17:14:06 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/55058 (lost cv-quals with typedef in template) 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 When we look through a typedef, we need to keep any cv-quals that were added to it. Tested x86_64-pc-linux-gnu, applying to 4.7 and trunk. commit fb7279cb5a26b73256da2faa1f8078670531ef17 Author: Jason Merrill Date: Thu Dec 6 16:04:22 2012 -0500 PR c++/55058 * pt.c (tsubst): Keep the quals when looking through a typedef. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 87cd337..33044e0 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11013,8 +11013,13 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) return r; } else - /* We don't have an instantiation yet, so drop the typedef. */ - t = DECL_ORIGINAL_TYPE (decl); + { + /* We don't have an instantiation yet, so drop the typedef. */ + int quals = cp_type_quals (t); + t = DECL_ORIGINAL_TYPE (decl); + t = cp_build_qualified_type_real (t, quals, + complain | tf_ignore_bad_quals); + } } if (type diff --git a/gcc/testsuite/g++.dg/template/typedef40.C b/gcc/testsuite/g++.dg/template/typedef40.C new file mode 100644 index 0000000..1d8be35 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/typedef40.C @@ -0,0 +1,21 @@ +// PR c++/55058 + +template +struct A { }; + +template +struct B { + B(const A T::* p); + typedef A D; +}; + +template +B::B(const D T::* p) { } + +struct C { + C() : e() {}; + + const A e; +}; + +B g(&C::e);