diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2020-01-10 14:27:05 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2020-01-10 14:27:05 +0000 |
commit | 2fb672a2574004a1e77c8ba83af539673f5cf659 (patch) | |
tree | ba1efe5fc64fac371ba9c620dc86893c9163bd94 /gcc/go | |
parent | 9c158322b6fdb47666f49c001dc54ea9f5c853e9 (diff) | |
download | gcc-2fb672a2574004a1e77c8ba83af539673f5cf659.zip gcc-2fb672a2574004a1e77c8ba83af539673f5cf659.tar.gz gcc-2fb672a2574004a1e77c8ba83af539673f5cf659.tar.bz2 |
compiler: permit duplicate methods from embedded interfaces
This is a language change for Go 1.14.
Updates golang/go#6977
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/214240
From-SVN: r280109
Diffstat (limited to 'gcc/go')
-rw-r--r-- | gcc/go/gofrontend/MERGE | 2 | ||||
-rw-r--r-- | gcc/go/gofrontend/types.cc | 26 |
2 files changed, 18 insertions, 10 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 9189bed..e7f037a 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -92ee4c2e295fc760105f187f6ea6dc65c81fa892 +98c4c21b52afd6384f9364527bd7f5f9a1c752cf 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/types.cc b/gcc/go/gofrontend/types.cc index 27d53df..d6cd326 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -8943,8 +8943,12 @@ Interface_type::finalize_methods() continue; } + const Typed_identifier_list* imethods = it->parse_methods_; + if (imethods == NULL) + continue; + Named_type* nt = t->named_type(); - if (nt != NULL && it->parse_methods_ != NULL) + if (nt != NULL) { std::vector<Named_type*>::const_iterator q; for (q = seen.begin(); q != seen.end(); ++q) @@ -8960,22 +8964,26 @@ Interface_type::finalize_methods() seen.push_back(nt); } - const Typed_identifier_list* imethods = it->parse_methods_; - if (imethods == NULL) - continue; for (Typed_identifier_list::const_iterator q = imethods->begin(); q != imethods->end(); ++q) { if (q->name().empty()) inherit.push_back(*q); - else if (this->find_method(q->name()) == NULL) - this->all_methods_->push_back(Typed_identifier(q->name(), - q->type(), tl)); else - go_error_at(tl, "inherited method %qs is ambiguous", - Gogo::message_name(q->name()).c_str()); + { + const Typed_identifier* oldm = this->find_method(q->name()); + if (oldm == NULL) + this->all_methods_->push_back(Typed_identifier(q->name(), + 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()); + } } + + seen.pop_back(); } if (!this->all_methods_->empty()) |