From 4ce6b8c7947c25d2b6464d7a95f7d42f2bbc1032 Mon Sep 17 00:00:00 2001 From: ian Date: Wed, 5 Dec 2012 00:53:59 +0000 Subject: [PATCH] compiler: Make sure we produce an error for a call to a non-function. Fixes issue 19. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@194175 138bc75d-0d04-0410-961f-82ee72b054a4 --- 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 cceb60b4773..e16cd84d0a0 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -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 -- 2.11.0