From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18608 invoked by alias); 21 Dec 2012 12:35:39 -0000 Received: (qmail 18500 invoked by uid 22791); 21 Dec 2012 12:35:38 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,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; Fri, 21 Dec 2012 12:35:28 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBLCZRVA031223 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 21 Dec 2012 07:35:28 -0500 Received: from localhost (ovpn-116-51.ams2.redhat.com [10.36.116.51]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qBLCZQ8M025437 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 21 Dec 2012 07:35:27 -0500 Received: by localhost (Postfix, from userid 1000) id 85EF02C004D; Fri, 21 Dec 2012 13:35:25 +0100 (CET) From: Dodji Seketeli To: GCC Patches Cc: Jason Merrill Subject: [PATCH] PR c++/52343 - error with alias template as template template argument X-URL: http://www.redhat.com Date: Fri, 21 Dec 2012 12:35:00 -0000 Message-ID: <87a9t74m7m.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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 X-SW-Source: 2012-12/txt/msg01312.txt.bz2 Hello, In the example accompanying this patch, check_instantiated_arg tries to ensure that a non-type template argument should be a constant if it has integral or enumeration type. The problem is that an alias template which type-id is, e.g, an integer, looks like an argument that has integral/enumeration type: its TREE_TYPE is an integer type. So check_instantiated_arg mistenkaly barks that this integral non-type argument is not a constant. I am proposing to tighten the test in check_instantiated_arg to allow type template (and thus aliast template) arguments. Bootstrapped and tested on x86_64-unknown-linux-gnu against trunk. gcc/cp/ PR c++/52343 * pt.c (check_instantiated_arg): Allow type template arguments. gcc/testsuite/ PR c++/52343 * g++.dg/cpp0x/alias-decl-29.C: New test. --- gcc/cp/pt.c | 4 +++- gcc/testsuite/g++.dg/cpp0x/alias-decl-29.C | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/alias-decl-29.C diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 1b3f039..e2e8311 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -14425,7 +14425,9 @@ check_instantiated_arg (tree tmpl, tree t, tsubst_flags_t complain) constant. */ else if (TREE_TYPE (t) && INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (t)) - && !TREE_CONSTANT (t)) + && !TREE_CONSTANT (t) + /* Class template and alias template arguments should be OK. */ + && !DECL_TYPE_TEMPLATE_P (t)) { if (complain & tf_error) error ("integral expression %qE is not constant", t); diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-29.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-29.C new file mode 100644 index 0000000..f6cc695 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-29.C @@ -0,0 +1,10 @@ +// Origin: PR c++/52343 +// { dg-do compile { target c++11 } } + +template +using A = int; + +template class> +struct B {}; + +B b; -- Dodji