From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2116) id 5BE0D3858289; Mon, 10 Oct 2022 21:46:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5BE0D3858289 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665438380; bh=DR+S4WUV+oLGysUcCj90gWJn867KOQocimaz6lBfPGU=; h=From:To:Subject:Date:From; b=jACGyIaIarsT6Xz+P6GxmDTKbkFSFN9BncpprXaJIXq6I3mVtlJ7gVvBmyEZP6wrM 7qNytP+D7kK+cZqoLTGHtFD1vCIUc9wHIFRTpvfRbpAlnV3VhjZ7R+ddYkwyLCQ3A7 pHQkwXFnjQ+4939/VegWrPuyWV8GpExNnHzjYEGs= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Ian Lance Taylor To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3205] compiler: treat S("") as a string constant X-Act-Checkin: gcc X-Git-Author: Ian Lance Taylor X-Git-Refname: refs/heads/master X-Git-Oldrev: 0f6efd34c21ab6452aa846fd7e59acbccf15fbef X-Git-Newrev: 29b0fe393859729215b0db5d28f2faea30c6ec32 Message-Id: <20221010214620.5BE0D3858289@sourceware.org> Date: Mon, 10 Oct 2022 21:46:18 +0000 (GMT) List-Id: https://gcc.gnu.org/g:29b0fe393859729215b0db5d28f2faea30c6ec32 commit r13-3205-g29b0fe393859729215b0db5d28f2faea30c6ec32 Author: Ian Lance Taylor Date: Sun Oct 9 12:52:17 2022 -0700 compiler: treat 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. No 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. Fixes golang/go#56113 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/441555 Diff: --- gcc/go/gofrontend/MERGE | 2 +- gcc/go/gofrontend/expressions.cc | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) 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) {