From patchwork Sat Mar 30 02:56:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Dos Reis X-Patchwork-Id: 232509 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 2D9A72C00AD for ; Sat, 30 Mar 2013 13:56:35 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; q=dns; s=default; b=MQ5nqFf/s+FCx3Bo 6GUVJyHQDAuz8NMM3+xCTvAMkPBncnf4joSaqEXgcnqXJI7mtcJClDGkNemYzStD YPwAgUCrAraDojU52ZXU8dwoPXL0677GjPy49cKsDhD8/IbSP4TsPY33lXYzqlMP Jnm80ZKjsvZFxeZ/1QjpLd+NJvY= 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:from :to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; s=default; bh=vW5TxPaJ3vIX7MLjSgdAH4 sIddM=; b=r6jsprNdfVj8E1No8tKSpcb51Cy2du1A4dgYo4ac8u9uNEoIek9uGO 6Y2NZIY9l4w+LiwmQco/7K/2/ujpDLtkIm1V1sow98vsW66cDiL/hkD8py2DeKm+ n7kUGuJ/jp2BC3nGNbT2FiHpl2vlM0nvA5292CLM5daKKyt1HzsWQ= Received: (qmail 9848 invoked by alias); 30 Mar 2013 02:56:26 -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 9838 invoked by uid 89); 30 Mar 2013 02:56:19 -0000 X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, RP_MATCHES_RCVD autolearn=ham version=3.3.1 Received: from www.axiomatics.org (HELO mail.axiomatics.org) (66.228.53.191) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sat, 30 Mar 2013 02:56:17 +0000 Received: by mail.axiomatics.org (Postfix, from userid 1000) id BEAF0ED51; Fri, 29 Mar 2013 21:56:14 -0500 (CDT) From: Gabriel Dos Reis To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: Re: [var-template] Accept variable template declaration In-Reply-To: <515638D3.8010404@redhat.com> (Jason Merrill's message of "Fri, 29 Mar 2013 20:58:59 -0400") References: <87ip49et6x.fsf@euclid.axiomatics.org> <515638D3.8010404@redhat.com> Date: Fri, 29 Mar 2013 21:56:12 -0500 Message-ID: <87hajt61f7.fsf@euclid.axiomatics.org> Lines: 84 MIME-Version: 1.0 Jason Merrill writes: | On 03/29/2013 06:29 PM, Gabriel Dos Reis wrote: | > + if (TREE_CODE (t) != TEMPLATE_DECL | > + || !(DECL_NAMESPACE_SCOPE_P (t) || DECL_MEMBER_TEMPLATE_P (t))) | | Why check the scope? ah right, if it is a template the scope was already checked. | > - if (!TYPE_P (ctx) || !CLASSTYPE_TEMPLATE_INFO (ctx)) | > - permerror (DECL_SOURCE_LOCATION (decl), | > - "%qD is not a static data member of a class template", decl); | > + if (!TYPE_P (ctx) || !CLASSTYPE_TEMPLATE_INFO (ctx)) { | > + if (cxx_dialect < cxx1y) | > + permerror (DECL_SOURCE_LOCATION (decl), | > + "%qD is not a static data member of a class template", decl); | > + } | > else if (template_header_count > wanted) | | I think we still want to check for excess template headers. right your are. | > + else if (VAR_P (decl)) { | > + if (!DECL_DECLARED_CONSTEXPR_P (decl)) | > + error ("template declaration of non-constexpr variable %qD", decl); | > + } | | Open brace should be on a line by itself. oops, fixed. Too many coding standards... -- Gaby 2013-03-29 Gabriel Dos Reis * cp-tree.h (variable_template_p): Do not check scope. * pt.c (check_template_variable): Fix thinko from previous change. (push_template_decl_real): Fix formatting. Index: gcc/cp/cp-tree.h =================================================================== --- gcc/cp/cp-tree.h (revision 197259) +++ gcc/cp/cp-tree.h (working copy) @@ -4930,8 +4930,7 @@ inline bool variable_template_p (tree t) { - if (TREE_CODE (t) != TEMPLATE_DECL - || !(DECL_NAMESPACE_SCOPE_P (t) || DECL_MEMBER_TEMPLATE_P (t))) + if (TREE_CODE (t) != TEMPLATE_DECL) return false; if (tree r = DECL_TEMPLATE_RESULT (t)) return VAR_P (r); Index: gcc/cp/pt.c =================================================================== --- gcc/cp/pt.c (revision 197259) +++ gcc/cp/pt.c (working copy) @@ -2275,7 +2275,7 @@ permerror (DECL_SOURCE_LOCATION (decl), "%qD is not a static data member of a class template", decl); } - else if (template_header_count > wanted) + if (template_header_count > wanted) { pedwarn (DECL_SOURCE_LOCATION (decl), 0, "too many template headers for %D (should be %d)", @@ -4618,10 +4618,11 @@ && TYPE_DECL_ALIAS_P (decl)) /* alias-declaration */ gcc_assert (!DECL_ARTIFICIAL (decl)); - else if (VAR_P (decl)) { - if (!DECL_DECLARED_CONSTEXPR_P (decl)) - error ("template declaration of non-constexpr variable %qD", decl); - } + else if (VAR_P (decl)) + { + if (!DECL_DECLARED_CONSTEXPR_P (decl)) + error ("template declaration of non-constexpr variable %qD", decl); + } else { error ("template declaration of %q#D", decl);