public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Go patch committed: Only convert function type when necessary
@ 2014-04-17 20:01 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2014-04-17 20:01 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 443 bytes --]

This patch to the Go frontend fixes it to not convert the function type
in a call when calling an interface method.  The function type of an
interface method is not correct, since it does not include the receiver,
but the type of the method field is correct, and as such should not be
converted.  This is PR 60870.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Tested by Ulrich Weigand on PPC.  Committed
to mainline.

Ian


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1124 bytes --]

diff -r 43e2635914c2 go/expressions.cc
--- a/go/expressions.cc	Thu Apr 17 12:09:37 2014 -0700
+++ b/go/expressions.cc	Thu Apr 17 12:24:08 2014 -0700
@@ -9619,9 +9619,20 @@
       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)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-04-17 19:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-17 20:01 Go patch committed: Only convert function type when necessary Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).