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 ~r0 level=0$"
21 var x [32]byte // ERROR "moved to heap: x$"
30 func walk(np **Node) int { // ERROR "leaking param content: np"
39 n.left, n.right = n.right, n.left // ERROR "ignoring self-assignment"
46 // Test for bug where func var f used prototype's escape analysis results.
47 func prototype(xyz []string) {} // ERROR "xyz does not escape"
51 f = func(ss []string) { got = append(got, ss) } // ERROR "leaking param: ss" "func literal does not escape"
53 f([]string{s}) // ERROR "\[\]string{...} escapes to heap"