From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2100) id A07AD3870900; Sat, 22 Aug 2020 23:34:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A07AD3870900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1598139291; bh=HrnmTxX40jU64IopYL+WiMyEqUWwI0DitG7TWF0Xqpg=; h=From:To:Subject:Date:From; b=M+esrUPoVUP6jjvBb6O8HvSGgoTj7dNcq6RhcnoNiEX97ZT4AuTTZ4epxgXSxPzsZ /YRaQGgCTzasbMpW1PaGWKe2+WRN7ZLMsG8h22iinp2BnPTYkOeLwKBNIrF35GVqH5 CuHYPqXbih5ryuWEHGrbQC/0AY6keuuhmfvZ/BjU= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Giuliano Belinassi To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/autopar_devel] compiler: handle aliases to pointer types with interfaces X-Act-Checkin: gcc X-Git-Author: Ian Lance Taylor X-Git-Refname: refs/heads/devel/autopar_devel X-Git-Oldrev: fffd1a230944c0e9d486d327dc0a4e6c17942553 X-Git-Newrev: a68548df636a557a963bae6694f8c8cba5e349b7 Message-Id: <20200822233451.A07AD3870900@sourceware.org> Date: Sat, 22 Aug 2020 23:34:51 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Aug 2020 23:34:51 -0000 https://gcc.gnu.org/g:a68548df636a557a963bae6694f8c8cba5e349b7 commit a68548df636a557a963bae6694f8c8cba5e349b7 Author: Ian Lance Taylor Date: Fri Jul 10 10:28:34 2020 -0700 compiler: handle aliases to pointer types with interfaces Test case is https://golang.org/cl/241997. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/241998 Diff: --- gcc/go/gofrontend/MERGE | 2 +- gcc/go/gofrontend/types.cc | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 64b13f410e0..c65fd8eecfc 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -2ad0970e9da95024110cd3244e9e21313af70a5f +ce70fa16a73e3f162de01deab6b5d17783e6b76b 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 3459a3357a3..7f65b4a5db2 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -9208,6 +9208,7 @@ Interface_type::implements_interface(const Type* t, std::string* reason) const if (this->all_methods_ == NULL) return true; + t = t->unalias(); bool is_pointer = false; const Named_type* nt = t->named_type(); const Struct_type* st = t->struct_type(); @@ -9220,6 +9221,7 @@ Interface_type::implements_interface(const Type* t, std::string* reason) const { // If T is a pointer to a named type, then we need to look at // the type to which it points. + pt = pt->unalias(); is_pointer = true; nt = pt->named_type(); st = pt->struct_type(); @@ -10408,19 +10410,24 @@ Named_type::interface_method_table(Interface_type* interface, bool is_pointer) return Expression::make_error(this->location_); if (this->is_alias_) { - if (this->type_->named_type() != NULL) + Type* t = this->type_; + if (!is_pointer && t->points_to() != NULL) + { + t = t->points_to(); + is_pointer = true; + } + if (t->named_type() != NULL) { if (this->seen_alias_) return Expression::make_error(this->location_); this->seen_alias_ = true; - Named_type* nt = this->type_->named_type(); + Named_type* nt = t->named_type(); Expression* ret = nt->interface_method_table(interface, is_pointer); this->seen_alias_ = false; return ret; } - if (this->type_->struct_type() != NULL) - return this->type_->struct_type()->interface_method_table(interface, - is_pointer); + if (t->struct_type() != NULL) + return t->struct_type()->interface_method_table(interface, is_pointer); go_unreachable(); } return Type::interface_method_table(this, interface, is_pointer,