This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Go patch committed: Fix global var init to call with calls as args
- From: Ian Lance Taylor <iant at google dot com>
- To: gcc-patches at gcc dot gnu dot org, gofrontend-dev at googlegroups dot com
- Date: Tue, 04 Oct 2011 16:16:35 -0700
- Subject: Go patch committed: Fix global var init to call with calls as args
The Go frontend had a bug when initializing a global variable to a
function call when some of the arguments to the call were themselves
function calls. The code which enforces function call ordering was
accidentally causing the outermost function to be called twice. This
patch fixes the bug. Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu. Committed to mainline.
Ian
diff -r 50541425d168 go/gogo.cc
--- a/go/gogo.cc Wed Sep 28 06:13:03 2011 -0700
+++ b/go/gogo.cc Tue Oct 04 16:13:56 2011 -0700
@@ -2063,6 +2063,8 @@
return TRAVERSE_SKIP_COMPONENTS;
}
+ Expression* orig_init = init;
+
for (Find_eval_ordering::const_iterator p = find_eval_ordering.begin();
p != find_eval_ordering.end();
++p)
@@ -2087,6 +2089,9 @@
var->add_preinit_statement(this->gogo_, s);
}
+ if (init != orig_init)
+ var->set_init(init);
+
return TRAVERSE_SKIP_COMPONENTS;
}