github.com/euank/go@v0.0.0-20160829210321-495514729181/src/cmd/compile/internal/gc/testdata/closure_ssa.go (about)

     1  // Copyright 2015 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // map_ssa.go tests map operations.
     6  package main
     7  
     8  import "fmt"
     9  
    10  var failed = false
    11  
    12  //go:noinline
    13  func testCFunc_ssa() int {
    14  	a := 0
    15  	b := func() {
    16  		switch {
    17  		}
    18  		a++
    19  	}
    20  	b()
    21  	b()
    22  	return a
    23  }
    24  
    25  func testCFunc() {
    26  	if want, got := 2, testCFunc_ssa(); got != want {
    27  		fmt.Printf("expected %d, got %d", want, got)
    28  		failed = true
    29  	}
    30  }
    31  
    32  func main() {
    33  	testCFunc()
    34  
    35  	if failed {
    36  		panic("failed")
    37  	}
    38  }