From patchwork Fri Apr 13 19:37:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 152389 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 B5169B6F9A for ; Sat, 14 Apr 2012 05:40:12 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1334950814; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=e/Bmi3o XhFoyeIktgAGfyPfQYoM=; b=J10pwEEfggUk3tDNBkXugL3SXgxE4pP6Mo2/KpL 2JaXP+4lk3j8QUzDFJ7u3FE03jUpudEuYZRmPdQBn/vwkgj4USMB2trnOBcrMDe1 lyuLzmqtixzEEj2Vxs2eVLedrgwDPeMjW4aswuUyZ5H2IteXkgMqTjF5KZSDHn2f dTkg= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=tmzJyHWAvvkcbGxcpeQGWFBC5ln/ix8NDeXRkIMzQmlrO23lZEbFUhr1paC5Tp ZEMIxQqz+HbcdxhN5/TXd2/qPtI7ZkvEbnUqy7ZJouVD9ilfrv26Y4bPDZlPUJVX t7gk+0vJSXRGH2fqaAyypEeWmBIsv1u4es/iAO/zkV7bc=; Received: (qmail 17095 invoked by alias); 13 Apr 2012 19:40:05 -0000 Received: (qmail 17039 invoked by uid 22791); 13 Apr 2012 19:40:02 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, 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, 13 Apr 2012 19:39:48 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q3DJdmWS023804 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 13 Apr 2012 15:39:48 -0400 Received: from [10.3.113.125] (ovpn-113-125.phx2.redhat.com [10.3.113.125]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q3DJc2Nh011290 for ; Fri, 13 Apr 2012 15:38:06 -0400 Message-ID: <4F888094.502@redhat.com> Date: Fri, 13 Apr 2012 15:37:56 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/52824 (pack expansion and fixed template parameters) 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 One case that I missed in my patch for PR 35722. Tested x86_64-pc-linux-gnu, applying to trunk and 4.7. commit 9fa7eea3608b19b53cc2f3c9a8195cf811b02d84 Author: Jason Merrill Date: Fri Apr 13 13:37:26 2012 -0400 PR c++/52824 * pt.c (any_pack_expanson_args_p): New. (coerce_template_parms): Use it. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index ee38254..07a2cc0 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6725,6 +6725,20 @@ coerce_template_parameter_pack (tree parms, return argument_pack; } +/* Returns true if the template argument vector ARGS contains + any pack expansions, false otherwise. */ + +static bool +any_pack_expanson_args_p (tree args) +{ + int i; + if (args) + for (i = 0; i < TREE_VEC_LENGTH (args); ++i) + if (PACK_EXPANSION_P (TREE_VEC_ELT (args, i))) + return true; + return false; +} + /* Convert all template arguments to their appropriate types, and return a vector containing the innermost resulting template arguments. If any error occurs, return error_mark_node. Error and @@ -6790,6 +6804,7 @@ coerce_template_parms (tree parms, if ((nargs > nparms && !variadic_p) || (nargs < nparms - variadic_p && require_all_args + && !any_pack_expanson_args_p (inner_args) && (!use_default_args || (TREE_VEC_ELT (parms, nargs) != error_mark_node && !TREE_PURPOSE (TREE_VEC_ELT (parms, nargs)))))) diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-15.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-15.C index 2bc9b11..b23e402 100644 --- a/gcc/testsuite/g++.dg/cpp0x/alias-decl-15.C +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-15.C @@ -2,7 +2,7 @@ // { dg-options "-std=c++0x" } template //#1 -struct foo {}; // { dg-error "provided for|foo" } +struct foo {}; template struct P {}; @@ -10,8 +10,8 @@ struct P {}; template class... TT> struct bar { template - using mem = P...>;//#2 { dg-error "wrong number of|arguments" } + using mem = P...>;//#2 }; -bar::mem b;//#3 { dg-error "invalid type" } +bar::mem b;//#3 diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic123.C b/gcc/testsuite/g++.dg/cpp0x/variadic123.C new file mode 100644 index 0000000..f0ab9fc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic123.C @@ -0,0 +1,14 @@ +// PR c++/52824 +// { dg-do compile { target c++11 } } + +template +struct foo +{}; + +template +struct bar : foo +{}; + +int main() { + bar f; +}