]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.ssa] cmd/compile: implement OFALL
authorTodd Neal <todd@tneal.org>
Sat, 29 Aug 2015 02:19:40 +0000 (21:19 -0500)
committerTodd Neal <todd@tneal.org>
Sat, 29 Aug 2015 02:30:17 +0000 (02:30 +0000)
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>
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/gc/testdata/ctl_ssa.go

index c92c82da1d407ffdd9037af92fb237e6673b2817..08a3ac2635e63f605f32377e6803ed7d8320eeaf 100644 (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:
index f7c3b807990406c277d2bbc0178aba86e38f9720..49050110e53ae937647f93bcb7016d293e1ec690 100644 (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")
        }