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
Change-Id: I99f8f2b91db73b8cb07f415267a9bf2154e1ab54
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/441555
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
diff --git a/go/expressions.cc b/go/expressions.cc
index 247ae1b..71838b1 100644
--- a/go/expressions.cc
+++ b/go/expressions.cc
@@ -4092,6 +4092,9 @@
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)
{