From patchwork Tue Aug 27 19:42:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Butcher X-Patchwork-Id: 270209 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 "www.sourceware.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id E4C992C00DD for ; Wed, 28 Aug 2013 05:43:25 +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:date:message-id:in-reply-to:references; q=dns; s= default; b=CjBhRVrHjsQbwMdUjMwM+rgsrgD8SF8/DEFbv9o+hcUgI+DfnTvvJ UVBlORP3XP8ity+4YfopprZaVN4iD+8rAiO0oOeIjtLaGMRYKOWqxjTATiQiYKzD Um/ql17LPyLPyQamEomX4qy49fV1/xN0CLPEck70UxYgk3bHQnIf54= 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:date:message-id:in-reply-to:references; s= default; bh=1eUyogEg8R0dPlw/bRJkSObqQmc=; b=mSp0MrthK8eO/SaIuHPi 8ZmpG1FS7ZN3JdmVYmdOfgOcar/Ke4b8TrMPPsbHbVzpFjMA42sZDs2844y2epGG 6FAUDEe+LO00uvRFA0CyC5u1YagBIlD4j0RCNGGc38q0tSjUP5w6mr+g0qYGUynR IpAMRQwirIzSWAGHpmnwee0= Received: (qmail 15822 invoked by alias); 27 Aug 2013 19:43:09 -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 15761 invoked by uid 89); 27 Aug 2013 19:43:08 -0000 Received: from mail-wg0-f43.google.com (HELO mail-wg0-f43.google.com) (74.125.82.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 27 Aug 2013 19:43:08 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=ALL_TRUSTED, AWL, BAYES_00, FREEMAIL_FROM, KHOP_THREADED autolearn=ham version=3.3.2 X-HELO: mail-wg0-f43.google.com Received: by mail-wg0-f43.google.com with SMTP id z11so2211768wgg.10 for ; Tue, 27 Aug 2013 12:43:04 -0700 (PDT) X-Received: by 10.180.36.231 with SMTP id t7mr12704482wij.54.1377632584624; Tue, 27 Aug 2013 12:43:04 -0700 (PDT) Received: from sphere.lan (munkyhouse.force9.co.uk. [84.92.244.81]) by mx.google.com with ESMTPSA id ff5sm28553968wib.2.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 27 Aug 2013 12:43:03 -0700 (PDT) From: Adam Butcher To: Jason Merrill Cc: gcc-patches@gcc.gnu.org, Gabriel Dos Reis , Andrew Sutton , Adam Butcher Subject: [PATCH 2/4] Don't generate lambda conversion op if arglist has parameter pack. Date: Tue, 27 Aug 2013 20:42:51 +0100 Message-Id: <1377632573-14453-3-git-send-email-adam@jessamine.co.uk> In-Reply-To: <1377632573-14453-1-git-send-email-adam@jessamine.co.uk> References: <1377632573-14453-1-git-send-email-adam@jessamine.co.uk> * lambda.c (maybe_add_lambda_conv_op): Optimize argvec building and early out if CALLOP contains a function parameter pack. --- gcc/cp/lambda.c | 60 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 16 deletions(-) diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index e9bc7c5..4d76f82 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -770,8 +770,51 @@ maybe_add_lambda_conv_op (tree type) return; } + argvec = make_tree_vector (); + + /* Non-template conversion operators are defined directly. Templates are + deferred. In the non-template case, the nullptr instance of the stateless + lambda type is added to ARGVEC for build_call_a. In the template case it + is bound via build_min. */ + if (!generic_lambda_p) + { + arg = build1 (NOP_EXPR, TREE_TYPE (DECL_ARGUMENTS (callop)), + null_pointer_node); + argvec->quick_push (arg); + } + + /* Copy CALLOP's argument list (as per 'copy_list') as FN_ARGS in order to + declare the static member function "_FUN" below. For each arg append to + ARGVEC (converting from reference in the template call op case). Early out + if a parameter pack is found; conversion to function pointer is not + supported in this case. */ + tree fn_args = NULL_TREE; + { + tree src = DECL_CHAIN (DECL_ARGUMENTS (callop)); + tree tgt; + + while (src) + { + if (FUNCTION_PARAMETER_PACK_P (src)) + return; + + if (!fn_args) + fn_args = tgt = copy_node (src); + else + { + TREE_CHAIN (tgt) = copy_node (src); + tgt = TREE_CHAIN (tgt); + } + + mark_exp_read (tgt); + vec_safe_push (argvec, + generic_lambda_p ? convert_from_reference (tgt) : tgt); + + src = TREE_CHAIN (src); + } + } + tree fn_result = TREE_TYPE (TREE_TYPE (callop)); - tree fn_args = copy_list (DECL_CHAIN (DECL_ARGUMENTS (callop))); if (generic_lambda_p) { @@ -780,12 +823,6 @@ maybe_add_lambda_conv_op (tree type) implementation of the conversion operator. */ tree instance = build_nop (type, null_pointer_node); - argvec = make_tree_vector (); - for (arg = fn_args; arg; arg = DECL_CHAIN (arg)) - { - mark_exp_read (arg); - vec_safe_push (argvec, convert_from_reference (arg)); - } tree objfn = build_min (COMPONENT_REF, NULL_TREE, instance, DECL_NAME (callop), NULL_TREE); @@ -802,15 +839,6 @@ maybe_add_lambda_conv_op (tree type) } else { - arg = build1 (NOP_EXPR, TREE_TYPE (DECL_ARGUMENTS (callop)), - null_pointer_node); - argvec = make_tree_vector (); - argvec->quick_push (arg); - for (arg = fn_args; arg; arg = DECL_CHAIN (arg)) - { - mark_exp_read (arg); - vec_safe_push (argvec, arg); - } call = build_call_a (callop, argvec->length (), argvec->address ()); CALL_FROM_THUNK_P (call) = 1; if (MAYBE_CLASS_TYPE_P (TREE_TYPE (call)))