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

Fixes golang/go#10642.

From-SVN: r222827
This commit is contained in:
Ian Lance Taylor 2015-05-05 20:56:41 +00:00
parent 72130e916c
commit 39e740e8a7
1 changed files with 4 additions and 2 deletions

View File

@ -5194,13 +5194,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);