From patchwork Mon Aug 9 21:12:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 61320 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 C2CB3B70D1 for ; Tue, 10 Aug 2010 07:12:59 +1000 (EST) Received: (qmail 13149 invoked by alias); 9 Aug 2010 21:12:58 -0000 Received: (qmail 13139 invoked by uid 22791); 9 Aug 2010 21:12:57 -0000 X-SWARE-Spam-Status: No, hits=-6.0 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; Mon, 09 Aug 2010 21:12:52 +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.13.8/8.13.8) with ESMTP id o79LCpxk014949 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 9 Aug 2010 17:12:51 -0400 Received: from [IPv6:::1] (ovpn-113-22.phx2.redhat.com [10.3.113.22]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o79LCoRj019657 for ; Mon, 9 Aug 2010 17:12:50 -0400 Message-ID: <4C606F52.7060200@redhat.com> Date: Mon, 09 Aug 2010 17:12:50 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.11) Gecko/20100802 Lightning/1.0b1 Shredder/3.0.7pre MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/45236 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 In this testcase, adjusting the template arguments for the nested class template failed because we were trying to adjust the arguments for the enclosing class template again and failing. This is unnecessary; we already have the adjusted arguments from when we looked up the member template. So this patch just reuses any enclosing arguments. To improve compiler speed for template-heavy code, we ought to look more at avoiding redundant use of coerce_template_args like this; after I switched specialization lookup to use hash tables, coercion was at the top of the profile, with about 16% of compile time. Tested x86_64-pc-linux-gnu, applied to trunk. commit 7cf59ddcccb7809fa17ef1619d44adc85ab8000e Author: Jason Merrill Date: Mon Aug 9 16:08:59 2010 -0400 PR c++/45236 * pt.c (lookup_template_class): Don't re-coerce outer parms. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index bb6b1a0..02c54f9 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6540,11 +6540,16 @@ lookup_template_class (tree d1, i > 0 && t != NULL_TREE; --i, t = TREE_CHAIN (t)) { - tree a = coerce_template_parms (TREE_VALUE (t), - arglist, gen_tmpl, - complain, - /*require_all_args=*/true, - /*use_default_args=*/true); + tree a; + if (i == saved_depth) + a = coerce_template_parms (TREE_VALUE (t), + arglist, gen_tmpl, + complain, + /*require_all_args=*/true, + /*use_default_args=*/true); + else + /* Outer levels should have already been coerced. */ + a = TMPL_ARGS_LEVEL (arglist, i); /* Don't process further if one of the levels fails. */ if (a == error_mark_node) diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-104.C b/gcc/testsuite/g++.dg/cpp0x/variadic-104.C new file mode 100644 index 0000000..c693b33 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-104.C @@ -0,0 +1,16 @@ +// PR c++/45236 +// { dg-options -std=c++0x } + +template class foo; + +template class C, int... II, class S> +struct foo,S> +{ + template + struct bar { typedef int type; }; +}; + +template +struct A {}; + +foo, float>::bar x;