2020-07-26 23:08:56 -06:00
|
|
|
// errorcheck -0 -m -l
|
|
|
|
|
|
|
|
// Copyright 2020 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package p
|
|
|
|
|
2020-08-14 22:30:04 -06:00
|
|
|
type t [20000]*int
|
2020-07-26 23:08:56 -06:00
|
|
|
|
|
|
|
func (t) f() {
|
|
|
|
}
|
|
|
|
|
|
|
|
func x() {
|
2020-09-08 22:09:01 -06:00
|
|
|
x := t{}.f // ERROR "t{}.f escapes to heap"
|
2020-07-26 23:08:56 -06:00
|
|
|
x()
|
|
|
|
}
|
|
|
|
|
|
|
|
func y() {
|
|
|
|
var i int // ERROR "moved to heap: i"
|
2020-09-08 22:09:01 -06:00
|
|
|
y := (&t{&i}).f // ERROR "\(&t{...}\).f escapes to heap" "&t{...} escapes to heap"
|
2020-07-26 23:08:56 -06:00
|
|
|
y()
|
|
|
|
}
|
|
|
|
|
|
|
|
func z() {
|
|
|
|
var i int // ERROR "moved to heap: i"
|
2020-09-08 22:09:01 -06:00
|
|
|
z := t{&i}.f // ERROR "t{...}.f escapes to heap"
|
2020-07-26 23:08:56 -06:00
|
|
|
z()
|
|
|
|
}
|