summaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2013-09-04 04:32:07 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2013-09-04 04:32:07 +0000
commit37448b10e5af19980ecc199872ad81c7a7db9ed8 (patch)
tree487d0fe7cb4c027c6d68284bde8fe22198fa4e5c /gcc/go
parenta6149bb6e75eced33739c502ee22844281b4eb6f (diff)
downloadgcc-37448b10e5af19980ecc199872ad81c7a7db9ed8.tar.gz
compiler: expand arguments with multiple results for built-in functions.
Fixed https://code.google.com/p/go/issues/detail?id=5796. Official fixedbug will be added with change to gc. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202239 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/expressions.cc36
1 files changed, 15 insertions, 21 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 78a427398c2..0b010334229 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -9138,35 +9138,27 @@ Call_expression::do_lower(Gogo* gogo, Named_object* function,
// Because do_type will return an error type and thus prevent future
// errors, check for that case now to ensure that the error gets
// reported.
- if (this->get_function_type() == NULL)
+ Function_type* fntype = this->get_function_type();
+ if (fntype == NULL)
{
if (!this->fn_->type()->is_error())
this->report_error(_("expected function"));
return Expression::make_error(loc);
}
- // Recognize a call to a builtin function.
- Func_expression* fne = this->fn_->func_expression();
- if (fne != NULL
- && fne->named_object()->is_function_declaration()
- && fne->named_object()->func_declaration_value()->type()->is_builtin())
- return new Builtin_call_expression(gogo, this->fn_, this->args_,
- this->is_varargs_, loc);
-
// Handle an argument which is a call to a function which returns
// multiple results.
if (this->args_ != NULL
&& this->args_->size() == 1
- && this->args_->front()->call_expression() != NULL
- && this->fn_->type()->function_type() != NULL)
+ && this->args_->front()->call_expression() != NULL)
{
- Function_type* fntype = this->fn_->type()->function_type();
size_t rc = this->args_->front()->call_expression()->result_count();
if (rc > 1
- && fntype->parameters() != NULL
- && (fntype->parameters()->size() == rc
- || (fntype->is_varargs()
- && fntype->parameters()->size() - 1 <= rc)))
+ && ((fntype->parameters() != NULL
+ && (fntype->parameters()->size() == rc
+ || (fntype->is_varargs()
+ && fntype->parameters()->size() - 1 <= rc)))
+ || fntype->is_builtin()))
{
Call_expression* call = this->args_->front()->call_expression();
Expression_list* args = new Expression_list;
@@ -9180,6 +9172,11 @@ Call_expression::do_lower(Gogo* gogo, Named_object* function,
}
}
+ // Recognize a call to a builtin function.
+ if (fntype->is_builtin())
+ return new Builtin_call_expression(gogo, this->fn_, this->args_,
+ this->is_varargs_, loc);
+
// If this call returns multiple results, create a temporary
// variable for each result.
size_t rc = this->result_count();
@@ -9188,8 +9185,7 @@ Call_expression::do_lower(Gogo* gogo, Named_object* function,
std::vector<Temporary_statement*>* temps =
new std::vector<Temporary_statement*>;
temps->reserve(rc);
- const Typed_identifier_list* results =
- this->fn_->type()->function_type()->results();
+ const Typed_identifier_list* results = fntype->results();
for (Typed_identifier_list::const_iterator p = results->begin();
p != results->end();
++p)
@@ -9204,10 +9200,8 @@ Call_expression::do_lower(Gogo* gogo, Named_object* function,
// Handle a call to a varargs function by packaging up the extra
// parameters.
- if (this->fn_->type()->function_type() != NULL
- && this->fn_->type()->function_type()->is_varargs())
+ if (fntype->is_varargs())
{
- Function_type* fntype = this->fn_->type()->function_type();
const Typed_identifier_list* parameters = fntype->parameters();
go_assert(parameters != NULL && !parameters->empty());
Type* varargs_type = parameters->back().type();