aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2020-12-14 22:50:18 -0800
committerIan Lance Taylor <iant@golang.org>2020-12-15 13:00:54 -0800
commit788d204885c187d5604e3960d7c78e1523f04861 (patch)
treee2ce79aa75ebc897cb002c89141e6857c9ec869a /gcc/go
parent8a5b8fc719f5c5bd6bd732d95646193238343f39 (diff)
downloadgcc-788d204885c187d5604e3960d7c78e1523f04861.zip
gcc-788d204885c187d5604e3960d7c78e1523f04861.tar.gz
gcc-788d204885c187d5604e3960d7c78e1523f04861.tar.bz2
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
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/expressions.cc23
-rw-r--r--gcc/go/gofrontend/types.cc21
3 files changed, 37 insertions, 9 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index a596b24..a28294c 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 79ed445..adc1ebb 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()
@@ -907,6 +912,18 @@ Type_expression : public Expression
};
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
{
ast_dump_context->dump_type(this->type_);
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc
index f9097d5..ecb93b0 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<Named_type*> 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();
+ }
}
}