From: ian Date: Wed, 1 Feb 2012 20:40:31 +0000 (+0000) Subject: compiler: Don't crash on switch _ := v.(type). X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=98033ea96897636a1c76a1d73fe91d28c2123c99;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc index 1359f4cca183..10abfc036c3b 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 =