From patchwork Tue Apr 17 02:24:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 153025 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 8E54AB7031 for ; Tue, 17 Apr 2012 12:24:32 +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=1335234273; 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=QaxxChU HRUIOXKMeqoh6KWxwzFY=; b=AhJJ39K1cs9rcjzKdHkc4Sax/ihnh+OnjBO33M5 Nc20bKKpJDLETsQnjojRBGiUSp0dtsPA/uDLfhiEMRbXOHfHsU2vSHq+sV6nVaTz Z1q0AWtOh4a8c2HV7FEwzwuMb6zr4FVqFqaAiTdOUvBOwhUnWScFhjGH9bRvMUW8 ms8Q= 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=wSYehHCF0ZK/aP4nJh9xcg+4IjJnxgvBxZhns2/7aMZl6Bo3S65du+0kj8iwRr zVOQFxxae4aa9+DkOjqzM9kDgLdjF7k484FHY6ZXycWhIGIP1/8CTZ4/JN7dPJ2w eCPChJ5vVN+EAy2Qj5DmDuxk6Ji9L9KZVhtSlZ+SS/zb0=; Received: (qmail 29930 invoked by alias); 17 Apr 2012 02:24:25 -0000 Received: (qmail 29920 invoked by uid 22791); 17 Apr 2012 02:24:24 -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; Tue, 17 Apr 2012 02:24:07 +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 q3H2O6vs017475 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 16 Apr 2012 22:24:07 -0400 Received: from [10.3.113.15] ([10.3.113.15]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q3H2O6ej019188 for ; Mon, 16 Apr 2012 22:24:06 -0400 Message-ID: <4F8CD445.8010709@redhat.com> Date: Mon, 16 Apr 2012 22:24:05 -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++/52008 (ICE with variadic partial specialization) 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, the partial specialization has fewer template arguments than the primary template has parameters, which was confusing GCC. Let's give an error for this case because the partial specialization isn't more specialized than the primary template. Tested x86_64-pc-linux-gnu, applying to trunk. commit b7486132b037ea59ac7e6524085e4e765dc22852 Author: Jason Merrill Date: Mon Apr 16 12:49:13 2012 -0400 PR c++/52008 * pt.c (process_partial_specialization): Complain about a partial specialization with fewer args than primary template parms. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index fcefc94..d6144d5 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -4376,6 +4376,18 @@ process_partial_specialization (tree decl) (maintmpl))))) error ("partial specialization %qT does not specialize any template arguments", type); + /* A partial specialization that replaces multiple parameters of the + primary template with a pack expansion is less specialized for those + parameters. */ + if (nargs < DECL_NTPARMS (maintmpl)) + { + error ("partial specialization is not more specialized than the " + "primary template because it replaces multiple parameters " + "with a pack expansion"); + inform (DECL_SOURCE_LOCATION (maintmpl), "primary template here"); + return decl; + } + /* [temp.class.spec] A partially specialized non-type argument expression shall not diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic130.C b/gcc/testsuite/g++.dg/cpp0x/variadic130.C new file mode 100644 index 0000000..f73c8b5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic130.C @@ -0,0 +1,8 @@ +// PR c++/52008 +// { dg-do compile { target c++11 } } + +template +struct A; + +template +struct A<0, Ts...>; // { dg-error "not more specialized" }