From patchwork Mon Jun 20 14:25:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 101135 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 000C5B6F5F for ; Tue, 21 Jun 2011 00:26:09 +1000 (EST) Received: (qmail 32534 invoked by alias); 20 Jun 2011 14:26:07 -0000 Received: (qmail 32504 invoked by uid 22791); 20 Jun 2011 14:26:07 -0000 X-SWARE-Spam-Status: No, hits=-6.4 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, 20 Jun 2011 14:25:50 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p5KEPn7X004467 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 20 Jun 2011 10:25:49 -0400 Received: from [127.0.0.1] ([10.3.113.2]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p5KEPnRx022454 for ; Mon, 20 Jun 2011 10:25:49 -0400 Message-ID: <4DFF586C.9000701@redhat.com> Date: Mon, 20 Jun 2011 10:25:48 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/49205 (failure to use variadic template constructor as default constructor) 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 A variadic template can take no arguments, so it's a default constructor. Tested x86_64-pc-linux-gnu, applying to trunk. commit 9f50baae331019464a94de275ae370cfebb30600 Author: Jason Merrill Date: Sun Jun 19 21:55:11 2011 -0400 PR c++/49205 * call.c (sufficient_parms_p): Allow parameter packs too. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 05bf983..09d73d0 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -534,15 +534,16 @@ null_ptr_cst_p (tree t) return false; } -/* Returns nonzero if PARMLIST consists of only default parms and/or - ellipsis. */ +/* Returns nonzero if PARMLIST consists of only default parms, + ellipsis, and/or undeduced parameter packs. */ bool sufficient_parms_p (const_tree parmlist) { for (; parmlist && parmlist != void_list_node; parmlist = TREE_CHAIN (parmlist)) - if (!TREE_PURPOSE (parmlist)) + if (!TREE_PURPOSE (parmlist) + && !PACK_EXPANSION_P (TREE_VALUE (parmlist))) return false; return true; } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-default.C b/gcc/testsuite/g++.dg/cpp0x/variadic-default.C new file mode 100644 index 0000000..2625e25 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-default.C @@ -0,0 +1,12 @@ +// PR c++/49205 +// { dg-options -std=c++0x } + +#include + +struct A { + template A(T...); + A(std::initializer_list); + A(std::initializer_list); +}; + +A a{};