compiler: Do not declare type switch variable outside case statements.
authorIan Lance Taylor <ian@gcc.gnu.org>
Fri, 6 Mar 2015 00:27:32 +0000 (00:27 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Fri, 6 Mar 2015 00:27:32 +0000 (00:27 +0000)
commitaeb41dc5b633a87d0ebe69ed1ce0b7f0af24fa3e
tree046f5dcdb454e83a54280fc6fa5bd40a8f864333
parentc4571e0e36c9ff80c29ad562c779be2e8fa1b6b2
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/gogo.cc
gcc/go/gofrontend/parse.cc
gcc/go/gofrontend/parse.h
gcc/go/gofrontend/statements.cc
gcc/go/gofrontend/statements.h