mirror of
https://github.com/golang/go
synced 2024-10-05 22:21:23 -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:
parent
707af252d9
commit
67e43c1e3b
@ -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:
|
||||||
|
60
src/cmd/compile/internal/gc/testdata/ctl_ssa.go
vendored
60
src/cmd/compile/internal/gc/testdata/ctl_ssa.go
vendored
@ -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")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user