diff mbox

Go patch committed: Don't permit P.M for a pointer type

Message ID CAOyqgcXyxy0JMpVN8nG9zK4FhO7pKvvmtM9pSmnw2hKZaaunuw@mail.gmail.com
State New
Headers show

Commit Message

Ian Lance Taylor Aug. 22, 2016, 9:30 p.m. UTC
https://golang.org/issue/15722 points out that gccgo was incorrectly
permitting P.M to used as a method expression when P is a pointer
type.  This patch by Than McIntosh fixes the problem.  Bootstrapped
and ran Go testsuite on x86_64-pc-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 239486)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -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.
Index: gcc/go/gofrontend/expressions.cc
===================================================================
--- gcc/go/gofrontend/expressions.cc	(revision 239332)
+++ gcc/go/gofrontend/expressions.cc	(working copy)
@@ -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_expres
 	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%>",