From 98033ea96897636a1c76a1d73fe91d28c2123c99 Mon Sep 17 00:00:00 2001 From: ian Date: Wed, 1 Feb 2012 20:40:31 +0000 Subject: [PATCH] compiler: Don't crash on switch _ := v.(type). git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@183814 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/go/gofrontend/parse.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc index 1359f4c..10abfc0 100644 --- a/gcc/go/gofrontend/parse.cc +++ b/gcc/go/gofrontend/parse.cc @@ -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 = -- 2.7.4