From patchwork Thu Jan 27 20:36:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 80734 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 1C6DFB711E for ; Fri, 28 Jan 2011 07:37:04 +1100 (EST) Received: (qmail 31573 invoked by alias); 27 Jan 2011 20:37:02 -0000 Received: (qmail 31554 invoked by uid 22791); 27 Jan 2011 20:37:01 -0000 X-SWARE-Spam-Status: No, hits=-5.6 required=5.0 tests=AWL, BAYES_00, 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; Thu, 27 Jan 2011 20:36:55 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0RKarVh031661 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 27 Jan 2011 15:36:54 -0500 Received: from adjoa.redhat.com (ovpn-113-97.phx2.redhat.com [10.3.113.97]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p0RKapmF031506; Thu, 27 Jan 2011 15:36:52 -0500 From: Dodji Seketeli To: Jason Merrill Cc: GCC Patches Subject: Re: PR c++/47311 References: <4D3A054A.5080306@redhat.com> <4D403E4A.7070309@redhat.com> X-URL: http://www.redhat.com Date: Thu, 27 Jan 2011 21:36:51 +0100 In-Reply-To: <4D403E4A.7070309@redhat.com> (Jason Merrill's message of "Wed, 26 Jan 2011 10:31:22 -0500") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes 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 Jason Merrill writes: > Would it work to call fixup_template_parms from > cp_parser_template_declaration_after_export instead of adding this > flag? Yes it does work. Tested on x86_64-unknown-linux-gnu against trunk. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 7500826..934dab8 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5025,6 +5025,7 @@ extern bool is_auto (const_tree); extern tree process_template_parm (tree, location_t, tree, bool, bool, unsigned); extern tree end_template_parm_list (tree); +void fixup_template_parms (void); extern void end_template_decl (void); extern tree maybe_update_decl_type (tree, tree); extern bool check_default_tmpl_args (tree, tree, int, int, int); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 41f82ac..2b6a752 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -19919,8 +19919,11 @@ cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p) parameter_list = NULL_TREE; } else - /* Parse the template parameters. */ - parameter_list = cp_parser_template_parameter_list (parser); + { + /* Parse the template parameters. */ + parameter_list = cp_parser_template_parameter_list (parser); + fixup_template_parms (); + } /* Get the deferred access checks from the parameter list. These will be checked once we know what is being declared, as for a diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 7d39e1c..d59f32a 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -194,7 +194,6 @@ static tree template_parm_to_arg (tree t); static tree current_template_args (void); static tree fixup_template_type_parm_type (tree, int); static tree fixup_template_parm_index (tree, tree, int); -static void fixup_template_parms (void); static tree tsubst_template_parm (tree, tree, tsubst_flags_t); /* Make the current scope suitable for access checking when we are @@ -3614,8 +3613,6 @@ end_template_parm_list (tree parms) TREE_CHAIN (parm) = NULL_TREE; } - fixup_template_parms (); - --processing_template_parmlist; return saved_parmlist; @@ -3774,21 +3771,16 @@ fixup_template_parm (tree parm_desc, { /* PARM is a template template parameter. This is going to be interesting. */ - tree tparms, targs, innermost_args; + tree tparms, targs, innermost_args, t; int j; - /* First, fix up the type of the parm. */ + /* First, fix up the parms of the template template parm + because the parms are involved in defining the new canonical + type of the template template parm. */ - tree t = - fixup_template_type_parm_type (TREE_TYPE (parm), num_parms); - TREE_TYPE (parm) = t; - - TREE_VEC_ELT (fixedup_args, idx) = - template_parm_to_arg (parm_desc); - - /* Now we need to substitute the template parm types that - have been fixed up so far into the non-type template - parms of this template template parm. E.g, consider this: + /* So we need to substitute the template parm types that have + been fixed up so far into the template parms of this template + template parm. E.g, consider this: template class TT> class S; @@ -3827,6 +3819,14 @@ fixup_template_parm (tree parm_desc, TREE_VEC_LENGTH (tparms), targs); } + + /* Now fix up the type of the template template parm. */ + + t = fixup_template_type_parm_type (TREE_TYPE (parm), num_parms); + TREE_TYPE (parm) = t; + + TREE_VEC_ELT (fixedup_args, idx) = + template_parm_to_arg (parm_desc); } else if (TREE_CODE (parm) == PARM_DECL) { @@ -3882,11 +3882,11 @@ fixup_template_parm (tree parm_desc, pop_deferring_access_checks (); } -/* Walk current the template parms and properly compute the canonical +/* Walk the current template parms and properly compute the canonical types of the dependent types created during cp_parser_template_parameter_list. */ -static void +void fixup_template_parms (void) { tree arglist; @@ -3911,8 +3911,6 @@ fixup_template_parms (void) arglist = current_template_args (); arglist = add_outermost_template_args (arglist, fixedup_args); - fixedup_args = INNERMOST_TEMPLATE_ARGS (arglist); - /* Let's do the proper fixup now. */ for (i = 0; i < num_parms; ++i) fixup_template_parm (TREE_VEC_ELT (parameter_vec, i), diff --git a/gcc/testsuite/g++.dg/template/param2.C b/gcc/testsuite/g++.dg/template/param2.C new file mode 100644 index 0000000..d25b855 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/param2.C @@ -0,0 +1,8 @@ +// Origin PR c++/47311 +// { dg-do compile } + +template < typename > class A0; +template class TC = A0> class B0; + +template class A1; +template class TC = A1> class B1;