aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2012-12-05 00:53:44 +0000
committerIan Lance Taylor <iant@google.com>2012-12-05 00:53:44 +0000
commit7eb798c128e2bfa6721b07c2df129196ab5c702d (patch)
tree3d75810243ea981e4f6f0f67dc1a584d44ac9a0a /gcc/go
parent5b31bbfde1e89021c1140deafa76243c45ca8296 (diff)
compiler: Make sure we produce an error for a call to a non-function.
Fixes issue 19. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@194174 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/expressions.cc10
1 files changed, 10 insertions, 0 deletions
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