OSDN Git Service

compiler: Make sure we produce an error for a call to a non-function.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 5 Dec 2012 00:53:59 +0000 (00:53 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 5 Dec 2012 00:53:59 +0000 (00:53 +0000)
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

index cceb60b..e16cd84 100644 (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);
 
     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
   // Recognize a call to a builtin function.
   Func_expression* fne = this->fn_->func_expression();
   if (fne != NULL