3 // Copyright 2015 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.
7 // Test escape analysis for function parameters.
9 // In this test almost everything is BAD except the simplest cases
10 // where input directly flows to output.
14 func f(buf []byte) []byte { // ERROR "leaking param: buf to result ~r1 level=0$"
21 var x [32]byte // ERROR "moved to heap: x$"
22 g(&f(x[:])[0]) // ERROR "&f\(x\[:\]\)\[0\] escapes to heap$" "x escapes to heap$"
30 func walk(np **Node) int { // ERROR "leaking param content: np"
36 wl := walk(&n.left) // ERROR "walk &n.left does not escape"
37 wr := walk(&n.right) // ERROR "walk &n.right does not escape"
39 n.left, n.right = n.right, n.left