aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend/parse.h
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2015-03-06 00:27:32 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2015-03-06 00:27:32 +0000
commitaeb41dc5b633a87d0ebe69ed1ce0b7f0af24fa3e (patch)
tree046f5dcdb454e83a54280fc6fa5bd40a8f864333 /gcc/go/gofrontend/parse.h
parentc4571e0e36c9ff80c29ad562c779be2e8fa1b6b2 (diff)
downloadgcc-aeb41dc5b633a87d0ebe69ed1ce0b7f0af24fa3e.zip
gcc-aeb41dc5b633a87d0ebe69ed1ce0b7f0af24fa3e.tar.gz
gcc-aeb41dc5b633a87d0ebe69ed1ce0b7f0af24fa3e.tar.bz2
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
Diffstat (limited to 'gcc/go/gofrontend/parse.h')
-rw-r--r--gcc/go/gofrontend/parse.h10
1 files changed, 2 insertions, 8 deletions
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<std::pair<Statement*, Label*> > 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<Named_object*>*);
void type_switch_case(std::vector<Type*>*, 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_;
};