public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@golang.org>
To: gcc-patches <gcc-patches@gcc.gnu.org>,
	 gofrontend-dev <gofrontend-dev@googlegroups.com>
Subject: Go patch committed: Treat S("") as a string constant
Date: Mon, 10 Oct 2022 14:46:29 -0700	[thread overview]
Message-ID: <CAOyqgcW9LELz-3fnT05qAkV8POsV0omaCvxvugYX=SWat7iKyg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 476 bytes --]

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

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1013 bytes --]

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)
     {

                 reply	other threads:[~2022-10-10 21:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOyqgcW9LELz-3fnT05qAkV8POsV0omaCvxvugYX=SWat7iKyg@mail.gmail.com' \
    --to=iant@golang.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gofrontend-dev@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).