1
0
mirror of https://github.com/golang/go synced 2024-10-05 16:41:21 -06:00

[dev.ssa] cmd/compile: implement OFALL

Frontend has already rewriten fallthrough statements, we just need to
ignore them.

Change-Id: Iadf89b06a9f8f9e6e2e1e87c934f31add77a19a1
Reviewed-on: https://go-review.googlesource.com/14029
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
Todd Neal 2015-08-28 21:19:40 -05:00
parent 707af252d9
commit 67e43c1e3b
2 changed files with 61 additions and 1 deletions

View File

@ -430,7 +430,7 @@ func (s *state) stmt(n *Node) {
s.stmtList(n.List)
// No-ops
case OEMPTY, ODCLCONST, ODCLTYPE:
case OEMPTY, ODCLCONST, ODCLTYPE, OFALL:
// Expression statements
case OCALLFUNC, OCALLMETH, OCALLINTER:

View File

@ -57,11 +57,71 @@ func testEmptyRange() {
}
}
func switch_ssa(a int) int {
ret := 0
switch a {
case 5:
ret += 5
case 4:
ret += 4
case 3:
ret += 3
case 2:
ret += 2
case 1:
ret += 1
}
return ret
}
func fallthrough_ssa(a int) int {
ret := 0
switch a {
case 5:
ret++
fallthrough
case 4:
ret++
fallthrough
case 3:
ret++
fallthrough
case 2:
ret++
fallthrough
case 1:
ret++
}
return ret
}
func testFallthrough() {
for i := 0; i < 6; i++ {
if got := fallthrough_ssa(i); got != i {
println("fallthrough_ssa(i) =", got, "wanted", i)
}
}
}
func testSwitch() {
for i := 0; i < 6; i++ {
if got := switch_ssa(i); got != i {
println("switch_ssa(i) =", got, "wanted", i)
}
}
}
var failed = false
func main() {
testPhiControl()
testEmptyRange()
testSwitch()
testFallthrough()
if failed {
panic("failed")
}