From aeb41dc5b633a87d0ebe69ed1ce0b7f0af24fa3e Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 6 Mar 2015 00:27:32 +0000 Subject: compiler: Do not declare type switch variable outside case statements. For expressions containing a TypeSwitchGuard with a short variable declaration e.g. var := x.(type), the spec says that var is declared at the beginning of the implicit block for each in each clause. Previously, var was declared in the block for the switch statement and each implicit block, which led to errors if the type case clause referenced a type with a similar name as the declared variable. Fixes golang/go#10047. From-SVN: r221230 --- gcc/go/gofrontend/parse.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'gcc/go/gofrontend/parse.h') diff --git a/gcc/go/gofrontend/parse.h b/gcc/go/gofrontend/parse.h index 9dd3b16..734071a 100644 --- a/gcc/go/gofrontend/parse.h +++ b/gcc/go/gofrontend/parse.h @@ -156,11 +156,6 @@ class Parse // break or continue statement with no label. typedef std::vector > Bc_stack; - // Map from type switch variables to the variables they mask, so - // that a use of the type switch variable can become a use of the - // real variable. - typedef Unordered_map(Named_object*, Named_object*) Type_switch_vars; - // Parser nonterminals. void identifier_list(Typed_identifier_list*); Expression_list* expression_list(Expression*, bool may_be_sink, @@ -259,7 +254,8 @@ class Parse void expr_case_clause(Case_clauses*, bool* saw_default); Expression_list* expr_switch_case(bool*); Statement* type_switch_body(Label*, const Type_switch&, Location); - void type_case_clause(Named_object*, Type_case_clauses*, bool* saw_default); + void type_case_clause(const std::string&, Expression*, Type_case_clauses*, + bool* saw_default, std::vector*); void type_switch_case(std::vector*, bool*); void select_stat(Label*); void comm_clause(Select_clauses*, bool* saw_default); @@ -327,8 +323,6 @@ class Parse // References from the local function to variables defined in // enclosing functions. Enclosing_vars enclosing_vars_; - // Map from type switch variables to real variables. - Type_switch_vars type_switch_vars_; }; -- cgit v1.1