Don't crash if tuple init redefines non-variable.
authorIan Lance Taylor <ian@gcc.gnu.org>
Tue, 4 Jan 2011 21:15:26 +0000 (21:15 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Tue, 4 Jan 2011 21:15:26 +0000 (21:15 +0000)
From-SVN: r168484

gcc/go/gofrontend/parse.cc

index 13374f40bcc9fd9db7264a0ecfbbae1a3f53b828..9e62583f6c67a1b731f2ee12860285e2a3d73d7f 100644 (file)
@@ -1655,9 +1655,15 @@ Parse::init_vars_from_map(const Typed_identifier_list* vars, Type* type,
   if (!this->gogo_->in_global_scope())
     this->gogo_->add_statement(s);
   else if (!val_no->is_sink())
-    val_no->var_value()->add_preinit_statement(s);
+    {
+      if (val_no->is_variable())
+       val_no->var_value()->add_preinit_statement(s);
+    }
   else if (!no->is_sink())
-    no->var_value()->add_preinit_statement(s);
+    {
+      if (no->is_variable())
+       no->var_value()->add_preinit_statement(s);
+    }
   else
     {
       // Execute the map index expression just so that we can fail if
@@ -1716,9 +1722,15 @@ Parse::init_vars_from_receive(const Typed_identifier_list* vars, Type* type,
   if (!this->gogo_->in_global_scope())
     this->gogo_->add_statement(s);
   else if (!val_no->is_sink())
-    val_no->var_value()->add_preinit_statement(s);
+    {
+      if (val_no->is_variable())
+       val_no->var_value()->add_preinit_statement(s);
+    }
   else if (!no->is_sink())
-    no->var_value()->add_preinit_statement(s);
+    {
+      if (no->is_variable())
+       no->var_value()->add_preinit_statement(s);
+    }
   else
     {
       Named_object* dummy = this->create_dummy_global(Type::lookup_bool_type(),
@@ -1776,9 +1788,15 @@ Parse::init_vars_from_type_guard(const Typed_identifier_list* vars,
   if (!this->gogo_->in_global_scope())
     this->gogo_->add_statement(s);
   else if (!val_no->is_sink())
-    val_no->var_value()->add_preinit_statement(s);
+    {
+      if (val_no->is_variable())
+       val_no->var_value()->add_preinit_statement(s);
+    }
   else if (!no->is_sink())
-    no->var_value()->add_preinit_statement(s);
+    {
+      if (no->is_variable())
+       no->var_value()->add_preinit_statement(s);
+    }
   else
     {
       Named_object* dummy = this->create_dummy_global(type, NULL, location);