This patch to the Go frontend fixes the case where two different
methods on different types with the same method name both define a
type internally with the same name where the type requires a specific
type hash or equality function.  Before this patch those functions
would get the same, causing a compilation error.  This patch gives
them different names using the same approach as is done for the type
descriptor.  I sent out a test case to the master Go testsuite in
https://golang.org/cl/17081.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline and GCC 5 branch.

Ian
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE     (revision 230463)
+++ gcc/go/gofrontend/MERGE     (working copy)
@@ -1,4 +1,4 @@
-e3aef41ce0c5be81e2589e60d9cb0db1516e9e2d
+dfa74d975884f363c74d6a66a37b1703093fdba6
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/types.cc
===================================================================
--- gcc/go/gofrontend/types.cc  (revision 230463)
+++ gcc/go/gofrontend/types.cc  (working copy)
@@ -1769,7 +1769,16 @@ Type::specific_type_functions(Gogo* gogo
       const Named_object* in_function = name->in_function(&index);
       if (in_function != NULL)
        {
-         base_name += '$' + Gogo::unpack_hidden_name(in_function->name());
+         base_name.append(1, '$');
+         const Typed_identifier* rcvr =
+           in_function->func_value()->type()->receiver();
+         if (rcvr != NULL)
+           {
+             Named_type* rcvr_type = rcvr->type()->deref()->named_type();
+             base_name.append(Gogo::unpack_hidden_name(rcvr_type->name()));
+             base_name.append(1, '$');
+           }
+         base_name.append(Gogo::unpack_hidden_name(in_function->name()));
          if (index > 0)
            {
              char buf[30];

Reply via email to