diff options
author | Ian Lance Taylor <iant@golang.org> | 2022-10-09 12:52:17 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2022-10-10 14:45:57 -0700 |
commit | 29b0fe393859729215b0db5d28f2faea30c6ec32 (patch) | |
tree | 8cc81ccaddcbfced1d66d5e886eef9c443a95c59 /gcc/go/gofrontend/expressions.cc | |
parent | 0f6efd34c21ab6452aa846fd7e59acbccf15fbef (diff) | |
download | gcc-29b0fe393859729215b0db5d28f2faea30c6ec32.zip gcc-29b0fe393859729215b0db5d28f2faea30c6ec32.tar.gz gcc-29b0fe393859729215b0db5d28f2faea30c6ec32.tar.bz2 |
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
Diffstat (limited to 'gcc/go/gofrontend/expressions.cc')
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 247ae1b..71838b1 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) { |