compiler: lvalue context fixes in Unary_expression::do_get_backend
authorIan Lance Taylor <ian@gcc.gnu.org>
Thu, 8 Jun 2017 18:42:04 +0000 (18:42 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Thu, 8 Jun 2017 18:42:04 +0000 (18:42 +0000)
    A couple of the Backend::var_expression invocations in
    Unary_expression::do_get_backend were selecting "lvalue" context
    incorrectly (these var exprs were not in an assignment or LHS
    position); fix is to change back to "rvalue" context.

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

From-SVN: r249029

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

index 7142db00865fe508b967eecce7827af250bb0f81..a30f61a2963b525e9dc85df413b51b61135ffaba 100644 (file)
@@ -1,4 +1,4 @@
-4b857cde45939f0e9f3cf89b9e347b6f6ebe0f8f
+81d9f6d05c2bb92b2b3af02807713b6bed9bf053
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index eaf492f3501eda0c8b5924a4cff9972535be901c..5689c77c0d8dfe34dc27e1aa0691d5c8762b8ba8 100644 (file)
@@ -4370,7 +4370,7 @@ Unary_expression::do_get_backend(Translate_context* context)
          gogo->backend()->implicit_variable_set_init(implicit, buf, btype,
                                                      true, copy_to_heap, false,
                                                      bexpr);
-         bexpr = gogo->backend()->var_expression(implicit, VE_lvalue, loc);
+         bexpr = gogo->backend()->var_expression(implicit, VE_rvalue, loc);
 
          // If we are not copying a slice initializer to the heap,
          // then it can be changed by the program, so if it can
@@ -4380,7 +4380,7 @@ Unary_expression::do_get_backend(Translate_context* context)
              && this->expr_->type()->has_pointer())
            {
              Bexpression* root =
-                  gogo->backend()->var_expression(implicit, VE_lvalue, loc);
+                  gogo->backend()->var_expression(implicit, VE_rvalue, loc);
              root = gogo->backend()->address_expression(root, loc);
              Type* type = Type::make_pointer_type(this->expr_->type());
              gogo->add_gc_root(Expression::make_backend(root, type, loc));
@@ -4400,7 +4400,7 @@ Unary_expression::do_get_backend(Translate_context* context)
                                                 true, false, btype, loc);
           gogo->backend()->immutable_struct_set_init(decl, buf, true, false,
                                                      btype, loc, bexpr);
-          bexpr = gogo->backend()->var_expression(decl, VE_lvalue, loc);
+          bexpr = gogo->backend()->var_expression(decl, VE_rvalue, loc);
         }
 
       go_assert(!this->create_temp_ || this->expr_->is_variable());