]> Cypherpunks.ru repositories - gostls13.git/blob - test/initexp.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / initexp.go
1 // errorcheck -t 10
2
3 // Copyright 2021 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
6
7 package p
8
9 // The init cycle diagnosis used to take exponential time
10 // to traverse the call graph paths. This test case takes
11 // at least two minutes on a modern laptop with the bug
12 // and runs in a fraction of a second without it.
13 // 10 seconds (-t 10 above) should be plenty if the code is working.
14
15 var x = f() + z() // ERROR "initialization cycle"
16
17 func f() int { return a1() + a2() + a3() + a4() + a5() + a6() + a7() }
18 func z() int { return x }
19
20 func a1() int { return b1() + b2() + b3() + b4() + b5() + b6() + b7() }
21 func a2() int { return b1() + b2() + b3() + b4() + b5() + b6() + b7() }
22 func a3() int { return b1() + b2() + b3() + b4() + b5() + b6() + b7() }
23 func a4() int { return b1() + b2() + b3() + b4() + b5() + b6() + b7() }
24 func a5() int { return b1() + b2() + b3() + b4() + b5() + b6() + b7() }
25 func a6() int { return b1() + b2() + b3() + b4() + b5() + b6() + b7() }
26 func a7() int { return b1() + b2() + b3() + b4() + b5() + b6() + b7() }
27 func a8() int { return b1() + b2() + b3() + b4() + b5() + b6() + b7() }
28
29 func b1() int { return a1() + a2() + a3() + a4() + a5() + a6() + a7() }
30 func b2() int { return a1() + a2() + a3() + a4() + a5() + a6() + a7() }
31 func b3() int { return a1() + a2() + a3() + a4() + a5() + a6() + a7() }
32 func b4() int { return a1() + a2() + a3() + a4() + a5() + a6() + a7() }
33 func b5() int { return a1() + a2() + a3() + a4() + a5() + a6() + a7() }
34 func b6() int { return a1() + a2() + a3() + a4() + a5() + a6() + a7() }
35 func b7() int { return a1() + a2() + a3() + a4() + a5() + a6() + a7() }
36 func b8() int { return a1() + a2() + a3() + a4() + a5() + a6() + a7() }