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

Fixes issue 19.

From-SVN: r194175
This commit is contained in:
Ian Lance Taylor 2012-12-05 00:53:59 +00:00
parent 6654b20487
commit 032146f9a3
1 changed files with 10 additions and 0 deletions

View File

@ -8513,6 +8513,16 @@ Call_expression::do_lower(Gogo* gogo, Named_object* function,
return Expression::make_cast(this->fn_->type(), this->args_->front(),
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.
Func_expression* fne = this->fn_->func_expression();
if (fne != NULL