compiler: Don't crash on switch _ := v.(type).
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 1 Feb 2012 20:40:31 +0000 (20:40 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 1 Feb 2012 20:40:31 +0000 (20:40 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@183814 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/parse.cc

index 1359f4c..10abfc0 100644 (file)
@@ -4311,9 +4311,16 @@ Parse::type_switch_body(Label* label, const Type_switch& type_switch,
   Named_object* switch_no = NULL;
   if (!type_switch.name.empty())
     {
-      Variable* switch_var = new Variable(NULL, type_switch.expr, false, false,
-                                         false, type_switch.location);
-      switch_no = this->gogo_->add_variable(type_switch.name, switch_var);
+      if (Gogo::is_sink_name(type_switch.name))
+       error_at(type_switch.location,
+                "no new variables on left side of %<:=%>");
+      else
+       {
+         Variable* switch_var = new Variable(NULL, type_switch.expr, false,
+                                             false, false,
+                                             type_switch.location);
+         switch_no = this->gogo_->add_variable(type_switch.name, switch_var);
+       }
     }
 
   Type_switch_statement* statement =