From: Ian Lance Taylor Date: Tue, 15 Dec 2020 06:50:18 +0000 (-0800) Subject: compiler: avoid knock-on errors from invalid interfaces X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=788d204885c187d5604e3960d7c78e1523f04861;p=gcc.git compiler: avoid knock-on errors from invalid interfaces The test case for this is issue11614.go. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/278192 --- diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index a596b241a4e..a28294c594f 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -85c390ec75c6c3f3fbfe08f6dac58585588c6211 +10d3dd939d4cea7f40b76f8ff82c16aa12c01188 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 79ed44510a9..adc1ebb4643 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -174,7 +174,13 @@ Expression::export_name(Export_function_body* efb, const Named_object* no) void Expression::unused_value_error() { - this->report_error(_("value computed is not used")); + if (this->type()->is_error()) + { + go_assert(saw_errors()); + this->set_is_error(); + } + else + this->report_error(_("value computed is not used")); } // Note that this expression is an error. This is called by children @@ -888,8 +894,7 @@ Type_expression : public Expression { } void - do_check_types(Gogo*) - { this->report_error(_("invalid use of type")); } + do_check_types(Gogo*); Expression* do_copy() @@ -906,6 +911,18 @@ Type_expression : public Expression Type* type_; }; +void +Type_expression::do_check_types(Gogo*) +{ + if (this->type_->is_error()) + { + go_assert(saw_errors()); + this->set_is_error(); + } + else + this->report_error(_("invalid use of type")); +} + void Type_expression::do_dump_expression(Ast_dump_context* ast_dump_context) const { diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index f9097d5e130..ecb93b099db 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -8984,8 +8984,11 @@ Interface_type::finalize_methods() else if (this->find_method(p->name()) == NULL) this->all_methods_->push_back(*p); else - go_error_at(p->location(), "duplicate method %qs", - Gogo::message_name(p->name()).c_str()); + { + go_error_at(p->location(), "duplicate method %qs", + Gogo::message_name(p->name()).c_str()); + this->set_is_error(); + } } std::vector seen; @@ -9001,7 +9004,10 @@ Interface_type::finalize_methods() if (it == NULL) { if (!t->is_error()) - go_error_at(tl, "interface contains embedded non-interface"); + { + go_error_at(tl, "interface contains embedded non-interface"); + this->set_is_error(); + } continue; } if (it == this) @@ -9009,6 +9015,7 @@ Interface_type::finalize_methods() if (!issued_recursive_error) { go_error_at(tl, "invalid recursive interface"); + this->set_is_error(); issued_recursive_error = true; } continue; @@ -9027,6 +9034,7 @@ Interface_type::finalize_methods() if (*q == nt) { go_error_at(tl, "inherited interface loop"); + this->set_is_error(); break; } } @@ -9049,8 +9057,11 @@ Interface_type::finalize_methods() q->type(), tl)); else if (!Type::are_identical(q->type(), oldm->type(), Type::COMPARE_TAGS, NULL)) - go_error_at(tl, "duplicate method %qs", - Gogo::message_name(q->name()).c_str()); + { + go_error_at(tl, "duplicate method %qs", + Gogo::message_name(q->name()).c_str()); + this->set_is_error(); + } } }