]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR go/60870 (go interface methods broken on ppc64le (bug296.go))
authorIan Lance Taylor <ian@gcc.gnu.org>
Thu, 17 Apr 2014 19:27:22 +0000 (19:27 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Thu, 17 Apr 2014 19:27:22 +0000 (19:27 +0000)
PR go/60870

compiler: Don't convert function type for an interface method.

For an interface method the function type is the type without
the receiver, which is wrong since we are passing a receiver.
The interface method will always have the correct type in this
case, so no type conversion is necessary.

Also don't do the type conversion when calling a named
function, since in that case the type is also always correct.

The type can be wrong, and the conversion required, when the
function type refers to itself recursively.

From-SVN: r209494

gcc/go/gofrontend/expressions.cc

index 199461061d9dc32b3c47c82e80ca7783fae0fb04..25718944b7173f58cf7104d345c837afcc178a47 100644 (file)
@@ -9619,9 +9619,20 @@ Call_expression::do_get_tree(Translate_context* context)
       fn = Expression::make_compound(set_closure, fn, location);
     }
 
-  Btype* bft = fntype->get_backend_fntype(gogo);
   Bexpression* bfn = tree_to_expr(fn->get_tree(context));
-  bfn = gogo->backend()->convert_expression(bft, bfn, location);
+
+  // When not calling a named function directly, use a type conversion
+  // in case the type of the function is a recursive type which refers
+  // to itself.  We don't do this for an interface method because 1)
+  // an interface method never refers to itself, so we always have a
+  // function type here; 2) we pass an extra first argument to an
+  // interface method, so fntype is not correct.
+  if (func == NULL && !is_interface_method)
+    {
+      Btype* bft = fntype->get_backend_fntype(gogo);
+      bfn = gogo->backend()->convert_expression(bft, bfn, location);
+    }
+
   Bexpression* call = gogo->backend()->call_expression(bfn, fn_args, location);
 
   if (this->results_ != NULL)