3 //go:build !goexperiment.newinliner
5 // Copyright 2010 The Go Authors. All rights reserved.
6 // Use of this source code is governed by a BSD-style
7 // license that can be found in the LICENSE file.
9 // Test, using compiler diagnostic flags, that the escape analysis is working.
10 // Compiles but does not run. Inlining is enabled.
16 func alloc(x int) *int { // ERROR "can inline alloc" "moved to heap: x"
23 p = alloc(2) // ERROR "inlining call to alloc" "moved to heap: x"
25 // Escape analysis used to miss inlined code in closures.
27 func() { // ERROR "can inline f1.func1"
28 p = alloc(3) // ERROR "inlining call to alloc"
29 }() // ERROR "inlining call to f1.func1" "inlining call to alloc" "moved to heap: x"
31 f = func() { // ERROR "func literal escapes to heap" "can inline f1.func2"
32 p = alloc(3) // ERROR "inlining call to alloc" "moved to heap: x"
37 func f2() {} // ERROR "can inline f2"
39 // No inline for recover; panic now allowed to inline.
40 func f3() { panic(1) } // ERROR "can inline f3" "1 escapes to heap"
41 func f4() { recover() }
43 func f5() *byte { // ERROR "can inline f5"
47 t := new(T) // ERROR "new.T. escapes to heap"
51 func f6() *byte { // ERROR "can inline f6"
57 t := new(T) // ERROR "new.T. escapes to heap"