From patchwork Thu Dec 24 01:50:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 1420362 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=yb8JfxeV; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D1Y2M2ZK9z9sWm for ; Thu, 24 Dec 2020 12:51:04 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E6AD53893645; Thu, 24 Dec 2020 01:51:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E6AD53893645 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1608774661; bh=Nto/s64D8TwPR3xLh2n3HipT6KP61xJpqkXY9viFCq8=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=yb8JfxeV+6l2C22Ej+PZswd3G6EnFm0580a2glVyr4tjlInlP7yqjDnnxaeAcCn/y GQHeJwE0+reYGMfZReTitSPKIwLJXKRW58TwlVOyjvoJcfmdKDFhA2M5HX0RVtciUa Ny0rZUracTkA6iDhmDHMVk58lvCQVBlj9+0IxotA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id A519D3850426 for ; Thu, 24 Dec 2020 01:50:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A519D3850426 Received: by mail-ed1-x535.google.com with SMTP id r5so892537eda.12 for ; Wed, 23 Dec 2020 17:50:58 -0800 (PST) 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=Nto/s64D8TwPR3xLh2n3HipT6KP61xJpqkXY9viFCq8=; b=epV03aO59/SzOKAauxuzokyXE9SUdcIDQIEJmntaW6TR5gLQucHvwEOtYDd9K/VEiF y1Lvq//GwSu1XJLSZqhvvtS5cyj0Ey6LKXRhA79o1Q0XxjtMQgWO49p+ssHZCQEbT3Kq bdjjZ/rvqxXh/G76kuR0BcwkhYcwgMFLv54iGXX6y/wY7dvTHSMtpfySf1J7eV01/VGu HSdGUPR1EbZaRixGgPhQF16/vld4BkxX48u2T2Np7Qs/p44zoNHRJWOHQDNwswbje6Z/ UfKV3PIfG0GAC7uF9mU1B8PpRaHzVNsdjkIfxMdfCmYyhaG19qP1fUVzFd2bHdA6pXc5 CdFg== X-Gm-Message-State: AOAM531HkButbaohGAGGd9J6LXa1te4MeboeZVG2ydIvVikt3Bq5v7tt U9BR8QNlFecH0ELA7lTeZZ1olzjQmiUP+Iij1FrIipMa36edtw== X-Google-Smtp-Source: ABdhPJweDhYNg47hagK9T+wpsDYudiuhUVlkJN7g4UzPGKWlVNwajlccCiUQBXocgf2cB/y4M8hMXH4nzuUAbigGB7M= X-Received: by 2002:a05:6402:17:: with SMTP id d23mr27125623edu.341.1608774657531; Wed, 23 Dec 2020 17:50:57 -0800 (PST) MIME-Version: 1.0 Date: Wed, 23 Dec 2020 17:50:46 -0800 Message-ID: Subject: Go patch committed: Parenthesize channel type strings as needed To: gcc-patches , gofrontend-dev X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Ian Lance Taylor via Gcc-patches From: Ian Lance Taylor Reply-To: Ian Lance Taylor Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This patch to the Go frontend avoids the ambiguity between "chan <- (chan int)" and "chan (<- chan int)". This parenthesizes the same way as the gc compiler. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian a40029e3b185a4b4e16a2a83933f742ff48c9743 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 600d9769624..1e461f06e95 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -8d49adead59b8103f3bfeebd53ee508eda5ee94a +d67579759e1769c08148304b2d378ec0b05637d6 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index 16f0eb59a50..7d4c47f1c42 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -8845,7 +8845,22 @@ Channel_type::do_reflection(Gogo* gogo, std::string* ret) const if (!this->may_receive_) ret->append("<-"); ret->push_back(' '); + + bool need_paren = false; + if (this->may_send_ + && this->may_receive_ + && this->element_type_->channel_type() != NULL + && this->element_type_->unalias()->named_type() == NULL + && !this->element_type_->channel_type()->may_send()) + { + ret->push_back('('); + need_paren = true; + } + this->append_reflection(this->element_type_, gogo, ret); + + if (need_paren) + ret->push_back(')'); } // Export.