From bb748b89dfae944fe6e075f1b5d1c3d1501c0948 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 22 Aug 2016 21:30:49 +0000 Subject: [PATCH] compiler: don't permit P.M if P is a pointer type When lowering method expressions of the form "P.M" where P is a pointer type (e.g. "type P *T") make sure we examine the method set of P and not T during method lookup. Fixes golang/go#15722. Reviewed-on: https://go-review.googlesource.com/24843 From-SVN: r239675 --- gcc/go/gofrontend/MERGE | 2 +- gcc/go/gofrontend/expressions.cc | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index e6a0f8483f5..0cf4f03be01 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -affb1bf5fcd7abf05993c54313d8000b93a08d4a +0476944600d456b2616981fff90c77be5e06edd5 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 bdc14aa2208..803611d5442 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -11439,7 +11439,8 @@ Expression* Selector_expression::lower_method_expression(Gogo* gogo) { Location location = this->location(); - Type* type = this->left_->type(); + Type* left_type = this->left_->type(); + Type* type = left_type; const std::string& name(this->name_); bool is_pointer; @@ -11469,7 +11470,8 @@ Selector_expression::lower_method_expression(Gogo* gogo) imethod = it->find_method(name); } - if (method == NULL && imethod == NULL) + if ((method == NULL && imethod == NULL) + || (left_type->named_type() != NULL && left_type->points_to() != NULL)) { if (!is_ambiguous) error_at(location, "type %<%s%s%> has no method %<%s%>", -- 2.11.4.GIT