compiler: Don't make temporaries for constant string concatentation.
authorIan Lance Taylor <ian@gcc.gnu.org>
Tue, 5 May 2015 20:56:59 +0000 (20:56 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Tue, 5 May 2015 20:56:59 +0000 (20:56 +0000)
Fixes golang/go#10642.

From-SVN: r222828

gcc/go/gofrontend/expressions.cc

index 379bed47e9102065bd567e1ad77a16431bbb47d8..e811a8d2a447ab83a0eb6c69f71d7f9dbde74aaa 100644 (file)
@@ -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);