From: Ian Lance Taylor Date: Fri, 9 Jun 2017 04:35:57 +0000 (+0000) Subject: compiler: additional lvalue/rvalue context fixes X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1ee77fbdea58944b047de8ff88901aea4e93ed7d;p=gcc.git compiler: additional lvalue/rvalue context fixes Fix lvalue/rvalue context mixup Set_and_use_temporary_expression's do_get_backend() method. Enhance Mark_lvalue_varexprs to handle conversions and temporary reference expressions, since occasionally the front end emits code such as "deref(conv(tempref)) = ...". Reviewed-on: https://go-review.googlesource.com/45141 From-SVN: r249047 --- diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 3280bcfe1f8..1bfac59adef 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -82961ce59e8bb02598d963d2a05b3acca860d9dd +d4875b19266d5f726e0e32843b903075f5c50b4c The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 5689c77c0d8..d6d27eea8d3 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -962,7 +962,7 @@ Set_and_use_temporary_expression::do_get_backend(Translate_context* context) Location loc = this->location(); Gogo* gogo = context->gogo(); Bvariable* bvar = this->statement_->get_backend_variable(context); - Bexpression* lvar_ref = gogo->backend()->var_expression(bvar, VE_rvalue, loc); + Bexpression* lvar_ref = gogo->backend()->var_expression(bvar, VE_lvalue, loc); Named_object* fn = context->function(); go_assert(fn != NULL); @@ -970,7 +970,7 @@ Set_and_use_temporary_expression::do_get_backend(Translate_context* context) Bexpression* bexpr = this->expr_->get_backend(context); Bstatement* set = gogo->backend()->assignment_statement(bfn, lvar_ref, bexpr, loc); - Bexpression* var_ref = gogo->backend()->var_expression(bvar, VE_lvalue, loc); + Bexpression* var_ref = gogo->backend()->var_expression(bvar, VE_rvalue, loc); Bexpression* ret = gogo->backend()->compound_expression(set, var_ref, loc); return ret; } diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc index ae3873ed189..7a448d7a606 100644 --- a/gcc/go/gofrontend/statements.cc +++ b/gcc/go/gofrontend/statements.cc @@ -912,6 +912,21 @@ int Mark_lvalue_varexprs::expression(Expression** ppexpr) if (ue && ue->op() == OPERATOR_MULT) return TRAVERSE_CONTINUE; + Type_conversion_expression* ce = e->conversion_expression(); + if (ce) + return TRAVERSE_CONTINUE; + + Temporary_reference_expression* tre = + e->temporary_reference_expression(); + if (tre) + { + tre = new Temporary_reference_expression(tre->statement(), + tre->location()); + *ppexpr = tre; + tre->set_is_lvalue(); + return TRAVERSE_EXIT; + } + return TRAVERSE_EXIT; }