diff mbox

Go patch committed: A variable with a preinit needs an init fn

Message ID mcr62ule0f2.fsf@google.com
State New
Headers show

Commit Message

Ian Lance Taylor Dec. 23, 2010, 1:35 a.m. UTC
If a Go variable has a preinit block, then the package needs an
initialization function.  Previously this was not being marked reliably,
though it often worked as such variables generally also have an
initializer.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

diff -r e29943434443 go/gogo.cc
--- a/go/gogo.cc	Wed Dec 22 17:20:35 2010 -0800
+++ b/go/gogo.cc	Wed Dec 22 17:32:25 2010 -0800
@@ -1384,7 +1384,11 @@ 
 
 	  // If this is a global variable which requires runtime
 	  // initialization, we need an initialization function.
-	  if (!variable->is_global() || variable->init() == NULL)
+	  if (!variable->is_global())
+	    ;
+	  else if (variable->has_pre_init())
+	    this->need_init_fn_ = true;
+	  else if (variable->init() == NULL)
 	    ;
 	  else if (variable->type()->interface_type() != NULL)
 	    this->need_init_fn_ = true;