blob: 54f7b3efb19dd421377d87a2fab958bc5e52d8fc [file] [log] [blame]
Russ Cox77ccb162015-02-24 12:19:01 -05001// errorcheck -0 -m
2
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.
6
7// Test, using compiler diagnostic flags, that inlining is working.
8// Compiles but does not run.
9
10package foo
11
12import "unsafe"
13
14func add2(p *byte, n uintptr) *byte { // ERROR "can inline add2" "leaking param: p to result"
15 return (*byte)(add1(unsafe.Pointer(p), n)) // ERROR "inlining call to add1"
16}
17
18func add1(p unsafe.Pointer, x uintptr) unsafe.Pointer { // ERROR "can inline add1" "leaking param: p to result"
19 return unsafe.Pointer(uintptr(p) + x)
20}
21
22func f(x *byte) *byte { // ERROR "can inline f" "leaking param: x to result"
23 return add2(x, 1) // ERROR "inlining call to add2" "inlining call to add1"
24}