Commit 67e43c1e authored by Todd Neal's avatar Todd Neal

[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/14029Reviewed-by: default avatarJosh Bleecher Snyder <josharian@gmail.com>
parent 707af252
...@@ -430,7 +430,7 @@ func (s *state) stmt(n *Node) { ...@@ -430,7 +430,7 @@ func (s *state) stmt(n *Node) {
s.stmtList(n.List) s.stmtList(n.List)
// No-ops // No-ops
case OEMPTY, ODCLCONST, ODCLTYPE: case OEMPTY, ODCLCONST, ODCLTYPE, OFALL:
// Expression statements // Expression statements
case OCALLFUNC, OCALLMETH, OCALLINTER: case OCALLFUNC, OCALLMETH, OCALLINTER:
......
...@@ -57,11 +57,71 @@ func testEmptyRange() { ...@@ -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 var failed = false
func main() { func main() {
testPhiControl() testPhiControl()
testEmptyRange() testEmptyRange()
testSwitch()
testFallthrough()
if failed { if failed {
panic("failed") panic("failed")
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment