From patchwork Tue Jul 18 23:29:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 790681 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-458457-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="l0NHt7Wd"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xBxFs32FNz9s81 for ; Wed, 19 Jul 2017 09:29:34 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=byGaoZ6IcJc/H+TC46xqIKSD/n0hdv5jbly8bMXCsDdINI A7T7NswTiZm3DfbkVUOGq2HO4juvgnG0aabJTEHQXwp1QBbN/RuavYjz90LxI/cg uSgP4BA7/R0u2+DX+iraTL1MKniz317hzH4LGI1u4y6Ehy34gElxRjQn8p9hs= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=fe3JJ9z6YWbDGMLJNNqtolpqKeI=; b=l0NHt7WdYy2eW10XZ8vs 48T9rd0uivJK0m5fyISGCpsCaMegK1j6rD7WWleEcKPt4riEmlI4ki4lhmIe3DcE k7qBt2+u/SbiIEJZFfMcKWCvOauQw4HrYoGtSWaYoKjKjFY31rMR2m9CefPmoaXU goRZP5m52zjoZeH64fCxIAo= Received: (qmail 8101 invoked by alias); 18 Jul 2017 23:29: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 8092 invoked by uid 89); 18 Jul 2017 23:29:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=closure X-HELO: mail-oi0-f46.google.com Received: from mail-oi0-f46.google.com (HELO mail-oi0-f46.google.com) (209.85.218.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 18 Jul 2017 23:29:24 +0000 Received: by mail-oi0-f46.google.com with SMTP id x187so30216907oig.3 for ; Tue, 18 Jul 2017 16:29:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=p8tDIckZSgEC93WvLFfrf5/EkvDGsmPxHpModrhfDvY=; b=Ez3uNbA9QI2wjxDCXsQmvMSH3zQTtmzOXDK0lsBba47HiFGJOhMHnQlaP8OwMZU1qh YYWu6SOcjOairoC8SN+nDWiGEPVrXSIRyn/hv3Na32LrAGLA+VTb3sol65KbIJ3fmNXV cDfFfEbV1hJZVBGUhgbf1Du0FznRMpJBzUCvT3Vgj8VKMzU01McJ/d3M/rgRI75ZQK8/ 90x5wFPe+lnLEYQunelCGQpkqdfUulu9BQsbkAPb6eykmAcOGv6lKK9zQ1lCXFsRch2x fYePFCwFQbEd8uAGDH16Hfo5m7sIx4Dw4FaVoBN0WBE+oYByQhCyfmHYh3AbiqXtCPQi 8TqQ== X-Gm-Message-State: AIVw110VgUzbYk6XJoAR7vN2avR4a1JXPmjOb7nNcLBSt0zmjsPPTrKX NEOer2qLK6yhnfiwu4yQ+oTrSUnuoSXgC4g= X-Received: by 10.202.69.195 with SMTP id s186mr53472oia.84.1500420562746; Tue, 18 Jul 2017 16:29:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.208.20 with HTTP; Tue, 18 Jul 2017 16:29:22 -0700 (PDT) From: Ian Lance Taylor Date: Tue, 18 Jul 2017 16:29:22 -0700 Message-ID: Subject: Go patch committed: Insert type conversion for closure function value To: gcc-patches , "gofrontend-dev@googlegroups.com" This patch by Than McIntosh changes the Go frontend, in Func_expression::do_get_backend, when creating the backend representation for a closure, to create a backend type conversion to account for potential differences between the closure struct type (where the number of fields is dependent on the number of values referenced in the closure) and the generic function descriptor type (struct with single function pointer field). Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 250326) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -c49ddc84f3ce89310585aad23ab6e51ef5523748 +3d9ff9bc339942922f1be3bef07c6fe2978ad81a The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: gcc/go/gofrontend/expressions.cc =================================================================== --- gcc/go/gofrontend/expressions.cc (revision 249799) +++ gcc/go/gofrontend/expressions.cc (working copy) @@ -1204,7 +1204,14 @@ Func_expression::do_get_backend(Translat // expression. It is a pointer to a struct whose first field points // to the function code and whose remaining fields are the addresses // of the closed-over variables. - return this->closure_->get_backend(context); + Bexpression *bexpr = this->closure_->get_backend(context); + + // Introduce a backend type conversion, to account for any differences + // between the argument type (function descriptor, struct with a + // single field) and the closure (struct with multiple fields). + Gogo* gogo = context->gogo(); + Btype *btype = this->type()->get_backend(gogo); + return gogo->backend()->convert_expression(btype, bexpr, this->location()); } // Ast dump for function.