blob: 89392bfff1d4b1cc09a1084aa07eebed51e7f136 [file] [log] [blame]
Russ Coxfd178d62013-02-05 07:00:38 -05001// errorcheck -0 -m
2
3// Copyright 2013 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// Check go:noescape annotations.
8
9package p
10
11// The noescape comment only applies to the next func,
12// which must not have a body.
13
14//go:noescape
15
16func F1([]byte)
17
18func F2([]byte)
19
20func G() {
21 var buf1 [10]byte
22 F1(buf1[:]) // ERROR "buf1 does not escape"
23
24 var buf2 [10]byte // ERROR "moved to heap: buf2"
25 F2(buf2[:]) // ERROR "buf2 escapes to heap"
26}