From d59a4c82a6fc608880b83b4339b9721ead432e95 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 5 Dec 2012 00:53:44 +0000 Subject: [PATCH] compiler: Make sure we produce an error for a call to a non-function. Fixes issue 19. From-SVN: r194174 --- gcc/go/gofrontend/expressions.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 3734d9b0b23..9da9414c3a6 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -8544,6 +8544,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