...
1
2
3
4
5 package main
6
7 import (
8 "cmd/compile/internal/loopvar/testdata/inlines/a"
9 "cmd/compile/internal/loopvar/testdata/inlines/b"
10 "cmd/compile/internal/loopvar/testdata/inlines/c"
11 "fmt"
12 "os"
13 )
14
15 func sum(s []*int) int {
16 sum := 0
17 for _, pi := range s {
18 sum += *pi
19 }
20 return sum
21 }
22
23 var t []*int
24
25 func F() []*int {
26 var s []*int
27 for i, j := 0, 0; j < 10; i, j = i+1, j+1 {
28 s = append(s, &i)
29 t = append(s, &j)
30 }
31 return s
32 }
33
34 func main() {
35 f := F()
36 af := a.F()
37 bf, _ := b.F()
38 abf := a.Fb()
39 cf := c.F()
40
41 sf, saf, sbf, sabf, scf := sum(f), sum(af), sum(bf), sum(abf), sum(cf)
42
43 fmt.Printf("f, af, bf, abf, cf sums = %d, %d, %d, %d, %d\n", sf, saf, sbf, sabf, scf)
44
45
46
47
48
49 if os.Getenv("GOCOMPILEDEBUG") != "" && (sabf == 45 || sf == 45) {
50 os.Exit(11)
51 }
52 os.Exit(0)
53 }
54
View as plain text