diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-09-20 22:34:59 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-09-20 22:34:59 +0000 |
commit | 02a728277f44e65a12ff4d16304fe6b7d4f845d5 (patch) | |
tree | 61f79c06833821078065e6e56f4d0bad8c64dd47 /gcc/go | |
parent | 6fa297991193239a6f167b92a3c4fc3e78ff400a (diff) | |
download | gcc-02a728277f44e65a12ff4d16304fe6b7d4f845d5.zip gcc-02a728277f44e65a12ff4d16304fe6b7d4f845d5.tar.gz gcc-02a728277f44e65a12ff4d16304fe6b7d4f845d5.tar.bz2 |
Improve error for undefined name in imported package.
Avoid emitting some followon errors.
From-SVN: r179020
Diffstat (limited to 'gcc/go')
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 9 | ||||
-rw-r--r-- | gcc/go/gofrontend/parse.cc | 13 |
2 files changed, 17 insertions, 5 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 43bcb5e..4e9d8d8 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -9730,7 +9730,10 @@ Call_result_expression::do_type() if (fntype == NULL) { if (ce->issue_error()) - this->report_error(_("expected function")); + { + if (!ce->fn()->type()->is_error()) + this->report_error(_("expected function")); + } this->set_is_error(); return Type::make_error_type(); } @@ -10043,7 +10046,9 @@ Array_index_expression::do_check_types(Gogo*) this->report_error(_("index must be integer")); if (this->end_ != NULL && this->end_->type()->integer_type() == NULL - && !this->end_->is_nil_expression()) + && !this->end_->type()->is_error() + && !this->end_->is_nil_expression() + && !this->end_->is_error_expression()) this->report_error(_("slice end must be integer")); Array_type* array_type = this->array_->type()->array_type(); diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc index 2b65139..bf084e0 100644 --- a/gcc/go/gofrontend/parse.cc +++ b/gcc/go/gofrontend/parse.cc @@ -335,10 +335,17 @@ Parse::type_name(bool issue_error) bool ok = true; if (named_object == NULL) { - if (package != NULL) - ok = false; - else + if (package == NULL) named_object = this->gogo_->add_unknown_name(name, location); + else + { + const std::string& packname(package->package_value()->name()); + error_at(location, "reference to undefined identifer %<%s.%s%>", + Gogo::message_name(packname).c_str(), + Gogo::message_name(name).c_str()); + issue_error = false; + ok = false; + } } else if (named_object->is_type()) { |