Because of the efforts the Go frontend takes to avoid knock-on errors, it was possible for some erroneous code to get through without an error message. Specifically, code like v().NonexistentFunction() would not produce an error when v was not a function. This patch fixes that problem. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline and 4.7 branch.
Ian
diff -r 39b613a05301 -r 76d51e7d9209 go/expressions.cc --- a/go/expressions.cc Tue Dec 04 16:21:16 2012 -0800 +++ b/go/expressions.cc Tue Dec 04 16:52:53 2012 -0800 @@ -8544,6 +8544,16 @@ 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