From patchwork Mon Oct 10 21:46:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 1892 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1783318wrs; Mon, 10 Oct 2022 14:47:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6d1Q2h9Q/PZjeu1D7PTu7TY6zefWIcJJoV2bdDHDWELRb0qem3nR1mGaoaRe+JEmM6WU3U X-Received: by 2002:a05:6402:5409:b0:44f:1e05:1e8 with SMTP id ev9-20020a056402540900b0044f1e0501e8mr19829488edb.373.1665438471334; Mon, 10 Oct 2022 14:47:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665438471; cv=none; d=google.com; s=arc-20160816; b=c77R3KTcfa9nItVL8IrCTACq25d3MtnolSM6JnimSmbkMorjcUq0ClNtUfhjHGqAPe KvBJw+qOpUUlkSSwgzsbhdHghjXHtghTM8Bo6chl5Bf16cH/mGuxCVRrJ24zhA1lNo7k 8jZdkbeQZ4Iz6+AST34m+jHiKeia8X9MYC0AExQHJXi2dqWTfuvSi3m7AmijqLYjLr9z JiOIQLK3wsjRsap9wTpuhXmloKzX1Aik3Ahdctv9hVd41TFONsYeE4NDsjdxiHgPSASz xeO1X7DXpeMl99+dK60/JgORS64hVwciIVJhC36ekRcM7eSANFjvCHU0y2s+EkBeYLz5 O0Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:to:subject :message-id:date:mime-version:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=3396ArfzrgAX5pR5Q23QBkPtzOyvOrCRjta97g0Nmg0=; b=FAfgfILZTwYtkBqa8+u6PVe0De1+TS2TPhaMP4XkXpFFdMqx8bloi14D6/+woLL6kw M1pehIYuDMqGVa3IviXqTvCJKDdxUIbV9pdh1aXkow8B8OeWzAmpUUR1Fh1Se6JriW8k rGU1La3MCbzHLLxkqQZGxox5g1yVq+DA+PSlVyuCS7s2bf2g/WwTsa6KrPXR7NfrTnyr OqPR/3f601yHgMubobsFuTUgBilKNFhTL29Nrgh68RM4IVL9V//sT8CF3nhQnysLiHic U8uY+YQyK6CDOJ9KFEhidRqdH/f4hRTrS9FBLmDjo2a96JERPSqUXYSrZAt1PfRCeI+e 3vhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=irl1Gk5K; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id sd35-20020a1709076e2300b0073da774ff40si4296717ejc.122.2022.10.10.14.47.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 14:47:51 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=irl1Gk5K; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4396C385AC1F for ; Mon, 10 Oct 2022 21:47:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4396C385AC1F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665438470; bh=3396ArfzrgAX5pR5Q23QBkPtzOyvOrCRjta97g0Nmg0=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=irl1Gk5KssQiZpg17KSwJoSCNcYWiOrT3NZD6hde5yDO1QrOD3ENwLQni2viD82L7 Iz62ZB/5VCbnyQ3MMdjhhcb+nM+uB+tW/ct73t1tqPsOAtg0Up6RnZqMOE0I616YCF HA0NJSY6s5LHFKQD3s/cRmjqtrZL2Ze3I23Dgs4o= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by sourceware.org (Postfix) with ESMTPS id BE3A93858289 for ; Mon, 10 Oct 2022 21:46:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BE3A93858289 Received: by mail-pj1-x102d.google.com with SMTP id d7-20020a17090a2a4700b0020d268b1f02so4773979pjg.1 for ; Mon, 10 Oct 2022 14:46:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=3396ArfzrgAX5pR5Q23QBkPtzOyvOrCRjta97g0Nmg0=; b=1QGIEeuYf5SwdlSSAcOZ1nDkLikERL3JliGKoYU3AWDszxRkiO3xqOLfhFfsqakAlo uE3i6p8lxCQ2S33EhGF3QldODbsYwj5YKlGYsRR5Szt4x65V8lmIjLmgCddUrqkn7VS0 RZkOND1vbsagXHGbLsfL0g8+tyeLc7yYYcxATxHrzwp0essYzRERC+9m61MYoaFT8goD tleaBp0PnTp2MFDXVU7+VKpu4mTK3M7pb/YwPlzC3KOp51R1uZeb/2BW3s5zK9l8FoIn 6ge1D3Rn0DCAtr+a4jfUsb/Tv6r/n49mArYKOFprHShhPTXFg472Js66YbdEQxIbYWiI uzGw== X-Gm-Message-State: ACrzQf1jaU//0PnhsRWPikzP7IbEyFrC2p+gFbGDhYnYHyDkaWdjE0wq ymonuxwmLz0krzdRhtGBGCbLNdeGPKnbGm4s87FwurpkzR6jow== X-Received: by 2002:a17:902:70c4:b0:17c:f9fe:3200 with SMTP id l4-20020a17090270c400b0017cf9fe3200mr21210749plt.1.1665438401164; Mon, 10 Oct 2022 14:46:41 -0700 (PDT) MIME-Version: 1.0 Date: Mon, 10 Oct 2022 14:46:29 -0700 Message-ID: Subject: Go patch committed: Treat S("") as a string constant To: gcc-patches , gofrontend-dev X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746338810459222487?= X-GMAIL-MSGID: =?utf-8?q?1746338810459222487?= This Go frontend patch treats S("") as a string constant. The compiler neglected to notice that a conversion from a string constant to a string type was a valid string constant. I didn't add a test case because this only caused a compiler failure when compiling without optimization, which is not the normal case, and is not a case that we test. This fixes https://go.dev/issue/56113. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 29b0fe393859729215b0db5d28f2faea30c6ec32 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 1c2466090f1..5b95b38a541 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -164f2aeb1deec4c11e55b8bfb152ff7ff4c1dd4c +6c188108858e3ae8c8ea8e4cc55427d8cf01bbc8 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/expressions.cc b/gcc/go/gofrontend/expressions.cc index 247ae1bba34..71838b14629 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -4092,6 +4092,9 @@ Type_conversion_expression::do_numeric_constant_value( bool Type_conversion_expression::do_string_constant_value(std::string* val) const { + if (this->type_->is_string_type() && this->expr_->type()->is_string_type()) + return this->expr_->string_constant_value(val); + if (this->type_->is_string_type() && this->expr_->type()->integer_type() != NULL) {