Commit 5003ddad by Ian Lance Taylor

compiler: Don't make temporaries for constant string concatentation.

Fixes golang/go#10642.

From-SVN: r222828
parent 21c0a521
...@@ -5120,13 +5120,15 @@ Binary_expression::do_flatten(Gogo* gogo, Named_object*, ...@@ -5120,13 +5120,15 @@ Binary_expression::do_flatten(Gogo* gogo, Named_object*,
if (this->left_->type()->is_string_type() if (this->left_->type()->is_string_type()
&& this->op_ == OPERATOR_PLUS) && 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); temp = Statement::make_temporary(NULL, this->left_, loc);
inserter->insert(temp); inserter->insert(temp);
this->left_ = Expression::make_temporary_reference(temp, loc); this->left_ = Expression::make_temporary_reference(temp, loc);
} }
if (!this->right_->is_variable()) if (!this->right_->is_variable()
&& !this->right_->is_constant())
{ {
temp = temp =
Statement::make_temporary(this->left_->type(), this->right_, loc); Statement::make_temporary(this->left_->type(), this->right_, loc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment