Commit d59a4c82 by Ian Lance Taylor

compiler: Make sure we produce an error for a call to a non-function.

Fixes issue 19.

From-SVN: r194174
parent 54d04de7
...@@ -8544,6 +8544,16 @@ Call_expression::do_lower(Gogo* gogo, Named_object* function, ...@@ -8544,6 +8544,16 @@ Call_expression::do_lower(Gogo* gogo, Named_object* function,
return Expression::make_cast(this->fn_->type(), this->args_->front(), return Expression::make_cast(this->fn_->type(), this->args_->front(),
loc); loc);
// 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)
{
if (!this->fn_->type()->is_error())
this->report_error(_("expected function"));
return Expression::make_error(loc);
}
// Recognize a call to a builtin function. // Recognize a call to a builtin function.
Func_expression* fne = this->fn_->func_expression(); Func_expression* fne = this->fn_->func_expression();
if (fne != NULL if (fne != NULL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment