From patchwork Wed May 15 22:56:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 244198 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 2761A2C008A for ; Thu, 16 May 2013 08:56:32 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; q=dns; s=default; b=SnSYkoakj8itQkED QuUJjXf5Cd6d3qqkxQd+hH0HQ9GJQwGlXz+fn16bQy4tTL06g0pV4hJN25S+B2vi Nl89jO7iSgl/m+SoW3vjPu1rSDGUwafft+xFy9Af0wA8K7QF3+L4OyNpxbe63TbU +mEjO0iGuFXBnowgYum1BuDxOQo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; s=default; bh=cT9xnnd5AhLRmi8n6kJ0G7 wPLNg=; b=QxAaFmuf2R3t40pzUe3gZnm6bJsNcqg+Aai9ojBa3Q8qKQ+YHrc6Jb 1SWStUJXAsv1OO598jP+8vRiDb2qwVQH5dgOhjfs5pRaOT+BVUOXSEwTUEe6ViTe g6bAjNmVxfxxf0NiT2m2SVgWjfiwffHaT66+rtLGs4W/czAiLlnQ4= Received: (qmail 13878 invoked by alias); 15 May 2013 22:56:26 -0000 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 Received: (qmail 13859 invoked by uid 89); 15 May 2013 22:56:24 -0000 X-Spam-SWARE-Status: No, score=-6.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 15 May 2013 22:56:23 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4FMuMbF006464 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 15 May 2013 18:56:22 -0400 Received: from localhost (ovpn-116-40.ams2.redhat.com [10.36.116.40]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r4FMuKFQ030014 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 15 May 2013 18:56:21 -0400 Received: by localhost (Postfix, from userid 1000) id B26AB1634C1; Thu, 16 May 2013 00:56:19 +0200 (CEST) From: Dodji Seketeli To: Jason Merrill Cc: GCC Patches Subject: Re: PR c++/56782 - Regression with empty pack expansions References: <877gj0pb2x.fsf@redhat.com> <5193ABAA.6020106@redhat.com> X-URL: http://www.redhat.com Date: Thu, 16 May 2013 00:56:19 +0200 In-Reply-To: <5193ABAA.6020106@redhat.com> (Jason Merrill's message of "Wed, 15 May 2013 11:37:14 -0400") Message-ID: <87hai3vomk.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Jason Merrill writes: > On 05/15/2013 10:33 AM, Dodji Seketeli wrote: >> So let's rule out the particular case of a zero argument pack >> length. > > I don't think there's anything special about zero length; if > has_empty_arg is true and parm_packs is non-null, we want to return > true. Does that make sense to you? Yes, of course. So here is what bootstraped. gcc/cp/ * pt.c (use_pack_expansion_extra_args_p): When at least a parameter pack has an empty argument pack, and another parameter pack has no argument pack at all, use the PACK_EXPANSION_EXTRA mechanism. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 04dc4fc..b0be950 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -9202,8 +9202,15 @@ use_pack_expansion_extra_args_p (tree parm_packs, int arg_pack_len, bool has_empty_arg) { + /* If one pack has an expansion and another pack has a normal + argument or if one pack has an empty argument and an another + one hasn't then tsubst_pack_expansion cannot perform the + substitution and need to fall back on the + PACK_EXPANSION_EXTRA mechanism. */ if (parm_packs == NULL_TREE) return false; + else if (has_empty_arg) + return true; bool has_expansion_arg = false; for (int i = 0 ; i < arg_pack_len; ++i) @@ -9221,13 +9228,7 @@ use_pack_expansion_extra_args_p (tree parm_packs, has_non_expansion_arg = true; } - /* If one pack has an expansion and another pack has a normal - argument or if one pack has an empty argument another one - hasn't then tsubst_pack_expansion cannot perform the - substitution and need to fall back on the - PACK_EXPANSION_EXTRA mechanism. */ - if ((has_expansion_arg && has_non_expansion_arg) - || (has_empty_arg && (has_expansion_arg || has_non_expansion_arg))) + if (has_expansion_arg && has_non_expansion_arg) return true; } return false; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic143.C b/gcc/testsuite/g++.dg/cpp0x/variadic143.C new file mode 100644 index 0000000..7737b4c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic143.C @@ -0,0 +1,63 @@ +// PR c++/56782 +// { dg-options -std=c++0x } + +template +T&& declval(); + +struct is_convertible_impl { + template + static void sink(T); + + template(declval()))> + static auto test(int) -> char; + + template + static auto test(...) -> char(&)[2]; +}; + +template +struct is_convertible : is_convertible_impl +{ + static const bool value = sizeof(test(0)) == 1; +}; + +template +struct enable_if {}; + +template +struct enable_if { typedef T type; }; + +template +struct conditional { typedef If type; }; + +template +struct conditional { typedef Else type; }; + +template +struct and_; + +template<> +struct and_<> +{ + static const bool value = true; +}; + +template +struct and_

: P +{ +}; + +template +struct and_ : conditional::type +{ +}; + +template +struct Tuple { + template... >::value, int>::type + > + Tuple(U&&...){} +}; + +static_assert(is_convertible, Tuple<>>::value, "Ouch"); //#1