From patchwork Mon May 5 16:25:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 345774 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D9041140E57 for ; Tue, 6 May 2014 02:27:31 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; q=dns; s=default; b=uCQK6eLv4+/1h4fRn E1E/TRzSBk1NYwGhgbl1QWLADa5YZUHdqpVJT5L6u6GrYih76of+JXiwdAlz6SV8 f3iBmQnKIoaN4rr1Z2SCJ7T6nZzN+ZIr3nZuNLLPeMt8iWt8CqfZkSzCcvTr8w0C QjMgY6ofMV6l7R2M5C6+/vnpDs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; s=default; bh=6I1yNoZVhPmVZynCwjij1WH todA=; b=r407oULDmxGPFTdrMQRNfu49aZaNpFJzdkW0zroyjYCVaTj5avF1nxt yjpZ9yv+hjbWae1gHbdHBl3mfb5GIQsfncn8+5jRo8ijyBM9Nkdc0MdsiI07jtrL 29DNv5ihjLwmjaUKFZmM0709Zk8IqGLDg32fEGKHLGteIDtOzf4M= Received: (qmail 5775 invoked by alias); 5 May 2014 16:27:24 -0000 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 Received: (qmail 5766 invoked by uid 89); 5 May 2014 16:27:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 05 May 2014 16:27:22 +0000 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s45GRJDa022144 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 5 May 2014 16:27:20 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by ucsinet22.oracle.com (8.14.5+Sun/8.14.5) with ESMTP id s45GRJUS024578 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Mon, 5 May 2014 16:27:19 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s45GRIg1022810; Mon, 5 May 2014 16:27:19 GMT Received: from [192.168.1.4] (/79.9.225.61) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 May 2014 09:27:18 -0700 Message-ID: <5367BB74.6060805@oracle.com> Date: Mon, 05 May 2014 18:25:24 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Jason Merrill , "gcc-patches@gcc.gnu.org" Subject: Re: [C++ Patch] PR 60999 References: <5360BF35.2010903@oracle.com> <53655C31.2020104@redhat.com> <536573E9.2070702@oracle.com> <536792D6.30609@redhat.com> In-Reply-To: <536792D6.30609@redhat.com> X-IsSubscribed: yes Hi, On 05/05/2014 03:32 PM, Jason Merrill wrote: > On 05/03/2014 06:55 PM, Paolo Carlini wrote: >> On 05/03/2014 11:14 PM, Jason Merrill wrote: >>> Do you want CLASSTYPE_IS_TEMPLATE here? > >> Uhm, you mean something simple like the attached? Because certainly I >> tried it and didn't fully work (nsdmi-template7.C?) and for sure we >> would regress on the below (which we should probably also add to >> testsuite, I had it two days ago in my experiments...). > > Ah, yes, CLASSTYPE_IS_TEMPLATE is false for partial specializations. > What we want is a predicate to check for a class template or partial > specialization. Good, but is it Ok to use uses_template_parms for that? A few days ago I struggled to find something simpler ready to use, to no avail (well, this is probably well known to you, but there are surprisingly few places in pt.c where we explain either in comments or in obvious code that we are handling full (vs partial) specializations). (Well, minor improvement of the below, I think it would be ok to call dependent_type_p directly, but processing_template_decl must be 1 around it anyway) Paolo. Index: cp-tree.h =================================================================== --- cp-tree.h (revision 210068) +++ cp-tree.h (working copy) @@ -3160,6 +3160,11 @@ more_aggr_init_expr_args_p (const aggr_init_expr_a && !CLASSTYPE_USE_TEMPLATE (NODE) \ && PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (NODE))) +/* True if the given class type is a template or a partial specialization. */ +#define CLASSTYPE_IS_TEMPLATE_OR_PARTIAL_SPECIALIZATION(NODE) \ + (CLASSTYPE_TEMPLATE_INFO (NODE) \ + && uses_template_parms (NODE)) + /* The name used by the user to name the typename type. Typically, this is an IDENTIFIER_NODE, and the same as the DECL_NAME on the corresponding TYPE_DECL. However, this may also be a Index: pt.c =================================================================== --- pt.c (revision 210068) +++ pt.c (working copy) @@ -462,9 +462,12 @@ maybe_begin_member_template_processing (tree decl) bool nsdmi = TREE_CODE (decl) == FIELD_DECL; if (nsdmi) - decl = (CLASSTYPE_TEMPLATE_INFO (DECL_CONTEXT (decl)) - ? CLASSTYPE_TI_TEMPLATE (DECL_CONTEXT (decl)) - : NULL_TREE); + { + tree ctx = DECL_CONTEXT (decl); + decl = (CLASSTYPE_IS_TEMPLATE_OR_PARTIAL_SPECIALIZATION (ctx) + ? CLASSTYPE_TI_TEMPLATE (ctx) + : NULL_TREE); + } if (inline_needs_template_parms (decl, nsdmi)) { @@ -11519,8 +11522,8 @@ tsubst (tree t, tree args, tsubst_flags_t complain r = instantiate_alias_template (tmpl, gen_args, complain); } else if (DECL_CLASS_SCOPE_P (decl) - && CLASSTYPE_TEMPLATE_INFO (DECL_CONTEXT (decl)) - && uses_template_parms (DECL_CONTEXT (decl))) + && (CLASSTYPE_IS_TEMPLATE_OR_PARTIAL_SPECIALIZATION + (DECL_CONTEXT (decl)))) { tree tmpl = most_general_template (DECL_TI_TEMPLATE (decl)); tree gen_args = tsubst (DECL_TI_ARGS (decl), args, complain, in_decl);