diff mbox

Go patch committed: Report init cycles in method values

Message ID mcry4sf7sh0.fsf@iant-glaptop.roam.corp.google.com
State New
Headers show

Commit Message

Ian Lance Taylor Oct. 16, 2014, 6:57 p.m. UTC
This patch from Chris Manghane fixes the Go frontend to correctly report
initialization cycles involving method values.  He added a test case for
this in the master gc testsuite, which will be copied into the gccgo
testsuite in due course.  This is http://golang.org/issue/7961 .
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian
diff mbox

Patch

diff -r 72bb6aea3991 go/gogo.cc
--- a/go/gogo.cc	Thu Oct 16 10:09:29 2014 -0700
+++ b/go/gogo.cc	Thu Oct 16 11:55:53 2014 -0700
@@ -953,13 +953,14 @@ 
 	}
     }
 
-  // We traverse the code of any function we see.  Note that this
-  // means that we will traverse the code of a function whose address
-  // is taken even if it is not called.
+  // We traverse the code of any function or bound method we see.  Note that
+  // this means that we will traverse the code of a function or bound method
+  // whose address is taken even if it is not called.
   Func_expression* fe = e->func_expression();
-  if (fe != NULL)
-    {
-      const Named_object* f = fe->named_object();
+  Bound_method_expression* bme = e->bound_method_expression();
+  if (fe != NULL || bme != NULL)
+    {
+      const Named_object* f = fe != NULL ? fe->named_object() : bme->function();
       if (f->is_function() && f->package() == NULL)
 	{
 	  std::pair<Seen_objects::iterator, bool> ins =