From patchwork Fri Apr 13 19:40:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 152390 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 62139B700D for ; Sat, 14 Apr 2012 05:40:56 +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=1334950856; 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=Zg3uxDo F+jUdytdn1fJUj9GTATg=; b=GWSJqZBxrM6wT+OJzpjB7DxmLen3CRTJNUPCyw3 6rHf9BxqDBaRDF2tSbc8GU4ONCtSkR1wKf5f9uiuUFMeN2Ga+4ipY3VwwJA/Lpo7 bMP/a9+245Z5xsvsoIdb/0qa0sNnznSiFviG+JDP3/KyB2tC+i8jrX8+9rEJQYKK eqL8= 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=MK29+ZqZr1AzyjKAOEgJphpWT1nr+uQwuL5g7t3BHC3o4KtitNVtynJIMem5bJ iZSPQNOYqCv4nUiMuTkWN62ltXHME99GfAfyC/VrGNMF2lMvNDPoNTDecazh7asH y80P66cXqxD+OqSU3PeAojVqs8E380wV1EDkqVmU9vafU=; Received: (qmail 17875 invoked by alias); 13 Apr 2012 19:40:52 -0000 Received: (qmail 17865 invoked by uid 22791); 13 Apr 2012 19:40:51 -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:40:38 +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 q3DJecqi002187 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 13 Apr 2012 15:40:38 -0400 Received: from [10.3.113.125] (ovpn-113-125.phx2.redhat.com [10.3.113.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q3DJebC7005079 for ; Fri, 13 Apr 2012 15:40:38 -0400 Message-ID: <4F888135.60506@redhat.com> Date: Fri, 13 Apr 2012 15:40:37 -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; +}