diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2015-05-05 20:56:59 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2015-05-05 20:56:59 +0000 |
commit | 5003ddad85b7de334c87d5716393da52d471f241 (patch) | |
tree | 2e477c359a77ed28cac697fb3572c2a90c5d32cc /gcc | |
parent | 21c0a521e4c1059b59ec2f15fad7469134126d7c (diff) | |
download | gcc-5003ddad85b7de334c87d5716393da52d471f241.zip gcc-5003ddad85b7de334c87d5716393da52d471f241.tar.gz gcc-5003ddad85b7de334c87d5716393da52d471f241.tar.bz2 |
compiler: Don't make temporaries for constant string concatentation.
Fixes golang/go#10642.
From-SVN: r222828
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 379bed4..e811a8d 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -5120,13 +5120,15 @@ Binary_expression::do_flatten(Gogo* gogo, Named_object*, if (this->left_->type()->is_string_type() && this->op_ == OPERATOR_PLUS) { - if (!this->left_->is_variable()) + if (!this->left_->is_variable() + && !this->left_->is_constant()) { temp = Statement::make_temporary(NULL, this->left_, loc); inserter->insert(temp); this->left_ = Expression::make_temporary_reference(temp, loc); } - if (!this->right_->is_variable()) + if (!this->right_->is_variable() + && !this->right_->is_constant()) { temp = Statement::make_temporary(this->left_->type(), this->right_, loc); |