From 5003ddad85b7de334c87d5716393da52d471f241 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 5 May 2015 20:56:59 +0000 Subject: [PATCH] compiler: Don't make temporaries for constant string concatentation. Fixes golang/go#10642. From-SVN: r222828 --- gcc/go/gofrontend/expressions.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 379bed47e91..e811a8d2a44 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); -- 2.30.2