diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2016-08-22 21:30:49 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2016-08-22 21:30:49 +0000 |
commit | bb748b89dfae944fe6e075f1b5d1c3d1501c0948 (patch) | |
tree | a338751b498276068ff5ae59293747a796105a88 | |
parent | d79d6252758099b8424434df6227c8beaea68608 (diff) | |
download | gcc-bb748b89dfae944fe6e075f1b5d1c3d1501c0948.zip gcc-bb748b89dfae944fe6e075f1b5d1c3d1501c0948.tar.gz gcc-bb748b89dfae944fe6e075f1b5d1c3d1501c0948.tar.bz2 |
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
-rw-r--r-- | gcc/go/gofrontend/MERGE | 2 | ||||
-rw-r--r-- | 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 e6a0f84..0cf4f03 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 bdc14aa..803611d 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%>", |