diff mbox

Go patch committed: Fix sink receiver

Message ID mcrlinanutw.fsf@dhcp-172-18-216-180.mtv.corp.google.com
State New
Headers show

Commit Message

Ian Lance Taylor March 9, 2012, 6:37 a.m. UTC
This patch to the Go frontend fixes the handling of a function with a
sink receiver, as in

func (_ T) F()

I've added a test case for this to the master Go testsuite, which will
be copied into the gccgo testsuite in due course.  Bootstrapped and ran
Go testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

diff -r f3b4795ea475 go/gogo.cc
--- a/go/gogo.cc	Thu Mar 08 22:34:11 2012 -0800
+++ b/go/gogo.cc	Thu Mar 08 22:35:23 2012 -0800
@@ -628,7 +628,7 @@ 
       Variable* this_param = new Variable(receiver->type(), NULL, false,
 					  true, true, location);
       std::string rname = receiver->name();
-      if (rname.empty())
+      if (rname.empty() || Gogo::is_sink_name(rname))
 	{
 	  // We need to give receivers a name since they wind up in
 	  // DECL_ARGUMENTS.  FIXME.
@@ -638,8 +638,7 @@ 
 	  ++count;
 	  rname = buf;
 	}
-      if (!Gogo::is_sink_name(rname))
-	block->bindings()->add_variable(rname, NULL, this_param);
+      block->bindings()->add_variable(rname, NULL, this_param);
     }
 
   const Typed_identifier_list* parameters = type->parameters();