OSDN Git Service

compiler: Fix order of initialization bug with global var a, b = f().
[pf3gnuchains/gcc-fork.git] / gcc / go / gofrontend / gogo.cc
index 7bc0b55..15c814b 100644 (file)
@@ -32,6 +32,7 @@ Gogo::Gogo(Backend* backend, Linemap* linemap, int int_type_size,
     imported_unsafe_(false),
     packages_(),
     init_functions_(),
     imported_unsafe_(false),
     packages_(),
     init_functions_(),
+    var_deps_(),
     need_init_fn_(false),
     init_fn_name_(),
     imported_init_fns_(),
     need_init_fn_(false),
     init_fn_name_(),
     imported_init_fns_(),
@@ -3820,6 +3821,10 @@ void
 Variable::lower_init_expression(Gogo* gogo, Named_object* function,
                                Statement_inserter* inserter)
 {
 Variable::lower_init_expression(Gogo* gogo, Named_object* function,
                                Statement_inserter* inserter)
 {
+  Named_object* dep = gogo->var_depends_on(this);
+  if (dep != NULL && dep->is_variable())
+    dep->var_value()->lower_init_expression(gogo, function, inserter);
+
   if (this->init_ != NULL && !this->init_is_lowered_)
     {
       if (this->seen_)
   if (this->init_ != NULL && !this->init_is_lowered_)
     {
       if (this->seen_)