This patch from Chris Manghane changes the Go frontend to not use
temporaries for constants when doing string concatenation.  This fixes
http://golang.org/issue/10642.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline and GCC 5 branch.

Ian
diff -r b2bef4b0764a go/expressions.cc
--- a/go/expressions.cc Tue May 05 09:38:04 2015 -0700
+++ b/go/expressions.cc Tue May 05 13:50:49 2015 -0700
@@ -5120,13 +5120,15 @@
   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);

Reply via email to