compiler: fix double evaluation with interface field expression
authorIan Lance Taylor <ian@gcc.gnu.org>
Tue, 10 Jul 2018 00:55:28 +0000 (00:55 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Tue, 10 Jul 2018 00:55:28 +0000 (00:55 +0000)
    In Interface_field_reference_expression, the interface expression
    is used in two places, so a temporary variable is used. Previously,
    we used a Set_and_use_temporary_expression, which, when evaluated
    twice, causes double evaluation of the underlying expression. Fix
    by setting the temporary once and use Temporary_reference_expression
    instead.

    Fixes golang/go#26248.

    Reviewed-on: https://go-review.googlesource.com/122756

From-SVN: r262533

gcc/go/gofrontend/MERGE
gcc/go/gofrontend/expressions.cc

index e65c0bc574b172668969a8c5835b231c5f4083b9..8a63818951beabd1851cce03fb38632c68db8587 100644 (file)
@@ -1,4 +1,4 @@
-94738979a3422e845acf358a766aabf8b9275d43
+8ad67a72a4fa59efffc891e73ecf10020e3c565d
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 75b8b69383cea162d7b9a55f02d0c86c6f992f89..89b265b9b6bba6606e6e31cc6374e1f516a808fd 100644 (file)
@@ -11886,10 +11886,9 @@ Interface_field_reference_expression::do_flatten(Gogo*, Named_object*,
   if (!this->expr_->is_variable())
     {
       Temporary_statement* temp =
-       Statement::make_temporary(this->expr_->type(), NULL, this->location());
+       Statement::make_temporary(NULL, this->expr_, this->location());
       inserter->insert(temp);
-      this->expr_ = Expression::make_set_and_use_temporary(temp, this->expr_,
-                                                          this->location());
+      this->expr_ = Expression::make_temporary_reference(temp, this->location());
     }
   return this;
 }