]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
compiler: don't add pointer twice to value method of direct interface type
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 8 May 2019 04:29:46 +0000 (04:29 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 8 May 2019 04:29:46 +0000 (04:29 +0000)
    For a direct interface type T with a value method M, its pointer
    type (*T)'s method table includes a stub method of M which takes
    a (*T) as the receiver instead of a T. However, for the "typ"
    field of the method table entry, we added another layer of
    indirection, which makes it appear to take a **T, which is wrong.
    This causes problems when using reflect.Type.Method to get the
    method. This CL fixes the second, incorrect, indirection.

    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/175837

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@270999 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/MERGE
gcc/go/gofrontend/types.cc

index aafb52c90ad8b4f271e8d4ee4a30ee5d3e607e08..ed95dfd481d23744b14fdedb118d7336433093b5 100644 (file)
@@ -1,4 +1,4 @@
-dc9c1b43753f392fdc2045bcb7a4abaa44fe79f1
+e3ba8828baf60343316bb68002e94570ee63ad1e
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 5796d2d245f21ca51085caee8c910d8707b8ab95..371b65fc20effa9ceac80fbee190ae9577c4b21a 100644 (file)
@@ -3440,14 +3440,15 @@ Type::method_constructor(Gogo*, Type* method_type,
       vals->push_back(Expression::make_unary(OPERATOR_AND, s, bloc));
     }
 
-  Named_object* no =
-    ((this->points_to() != NULL
-      && this->points_to()->is_direct_iface_type()
-      && m->is_value_method())
-     ? m->iface_stub_object()
-     : (m->needs_stub_method()
-        ? m->stub_object()
-        : m->named_object()));
+  bool use_direct_iface_stub =
+    this->points_to() != NULL
+    && this->points_to()->is_direct_iface_type()
+    && m->is_value_method();
+  Named_object* no = (use_direct_iface_stub
+                      ? m->iface_stub_object()
+                      : (m->needs_stub_method()
+                         ? m->stub_object()
+                         : m->named_object()));
 
   Function_type* mtype;
   if (no->is_function())
@@ -3463,7 +3464,8 @@ Type::method_constructor(Gogo*, Type* method_type,
 
   ++p;
   go_assert(p->is_field_name("typ"));
-  bool want_pointer_receiver = !only_value_methods && m->is_value_method();
+  bool want_pointer_receiver = (!only_value_methods && m->is_value_method()
+                                && !use_direct_iface_stub);
   nonmethod_type = mtype->copy_with_receiver_as_param(want_pointer_receiver);
   vals->push_back(Expression::make_type_descriptor(nonmethod_type, bloc));