mirror of git://gcc.gnu.org/git/gcc.git
compiler: More cases that need a temporary for interface conversion.
From-SVN: r218952
This commit is contained in:
parent
6b0e0695a5
commit
16f72d88dd
|
|
@ -5142,6 +5142,9 @@ Expression*
|
||||||
Binary_expression::do_flatten(Gogo* gogo, Named_object*,
|
Binary_expression::do_flatten(Gogo* gogo, Named_object*,
|
||||||
Statement_inserter* inserter)
|
Statement_inserter* inserter)
|
||||||
{
|
{
|
||||||
|
if (this->classification() == EXPRESSION_ERROR)
|
||||||
|
return this;
|
||||||
|
|
||||||
Location loc = this->location();
|
Location loc = this->location();
|
||||||
Temporary_statement* temp;
|
Temporary_statement* temp;
|
||||||
if (this->left_->type()->is_string_type()
|
if (this->left_->type()->is_string_type()
|
||||||
|
|
@ -6876,11 +6879,17 @@ Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function,
|
||||||
Expression*
|
Expression*
|
||||||
Builtin_call_expression::do_flatten(Gogo*, Named_object*,
|
Builtin_call_expression::do_flatten(Gogo*, Named_object*,
|
||||||
Statement_inserter* inserter)
|
Statement_inserter* inserter)
|
||||||
{
|
|
||||||
if (this->code_ == BUILTIN_APPEND
|
|
||||||
|| this->code_ == BUILTIN_COPY)
|
|
||||||
{
|
{
|
||||||
Location loc = this->location();
|
Location loc = this->location();
|
||||||
|
|
||||||
|
switch (this->code_)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BUILTIN_APPEND:
|
||||||
|
case BUILTIN_COPY:
|
||||||
|
{
|
||||||
Type* at = this->args()->front()->type();
|
Type* at = this->args()->front()->type();
|
||||||
for (Expression_list::iterator pa = this->args()->begin();
|
for (Expression_list::iterator pa = this->args()->begin();
|
||||||
pa != this->args()->end();
|
pa != this->args()->end();
|
||||||
|
|
@ -6901,6 +6910,23 @@ Builtin_call_expression::do_flatten(Gogo*, Named_object*,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BUILTIN_PANIC:
|
||||||
|
for (Expression_list::iterator pa = this->args()->begin();
|
||||||
|
pa != this->args()->end();
|
||||||
|
++pa)
|
||||||
|
{
|
||||||
|
if (!(*pa)->is_variable() && (*pa)->type()->interface_type() != NULL)
|
||||||
|
{
|
||||||
|
Temporary_statement* temp =
|
||||||
|
Statement::make_temporary(NULL, *pa, loc);
|
||||||
|
inserter->insert(temp);
|
||||||
|
*pa = Expression::make_temporary_reference(temp, loc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -421,6 +421,28 @@ Temporary_statement::do_check_types(Gogo*)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Flatten a temporary statement: add another temporary when it might
|
||||||
|
// be needed for interface conversion.
|
||||||
|
|
||||||
|
Statement*
|
||||||
|
Temporary_statement::do_flatten(Gogo*, Named_object*, Block*,
|
||||||
|
Statement_inserter* inserter)
|
||||||
|
{
|
||||||
|
if (this->type_ != NULL
|
||||||
|
&& this->init_ != NULL
|
||||||
|
&& !Type::are_identical(this->type_, this->init_->type(), false, NULL)
|
||||||
|
&& this->init_->type()->interface_type() != NULL
|
||||||
|
&& !this->init_->is_variable())
|
||||||
|
{
|
||||||
|
Temporary_statement *temp =
|
||||||
|
Statement::make_temporary(NULL, this->init_, this->location());
|
||||||
|
inserter->insert(temp);
|
||||||
|
this->init_ = Expression::make_temporary_reference(temp,
|
||||||
|
this->location());
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
// Convert to backend representation.
|
// Convert to backend representation.
|
||||||
|
|
||||||
Bstatement*
|
Bstatement*
|
||||||
|
|
@ -440,9 +462,10 @@ Temporary_statement::do_get_backend(Translate_context* context)
|
||||||
binit = this->init_->get_backend(context);
|
binit = this->init_->get_backend(context);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Expression* init = Expression::make_cast(this->type_, this->init_,
|
Expression* init = Expression::convert_for_assignment(context->gogo(),
|
||||||
|
this->type_,
|
||||||
|
this->init_,
|
||||||
this->location());
|
this->location());
|
||||||
context->gogo()->lower_expression(context->function(), NULL, &init);
|
|
||||||
binit = init->get_backend(context);
|
binit = init->get_backend(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -550,6 +550,9 @@ class Temporary_statement : public Statement
|
||||||
void
|
void
|
||||||
do_check_types(Gogo*);
|
do_check_types(Gogo*);
|
||||||
|
|
||||||
|
Statement*
|
||||||
|
do_flatten(Gogo*, Named_object*, Block*, Statement_inserter*);
|
||||||
|
|
||||||
Bstatement*
|
Bstatement*
|
||||||
do_get_backend(Translate_context*);
|
do_get_backend(Translate_context*);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue