From fa9fe7a5a74938c73044fdd2ccd735bf0d703773 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 1 Feb 2012 20:40:31 +0000 Subject: compiler: Don't crash on switch _ := v.(type). From-SVN: r183814 --- 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 = -- cgit v1.1