1 // errorcheck -0 -m -live -std
3 //go:build !windows && !js && !wasip1
5 // Copyright 2015 The Go Authors. All rights reserved.
6 // Use of this source code is governed by a BSD-style
7 // license that can be found in the LICENSE file.
9 // Test escape analysis and liveness inferred for uintptrkeepalive functions.
11 // This behavior is enabled automatically for function declarations with no
12 // bodies (assembly, linkname), as well as explicitly on complete functions
13 // with //go:uintptrkeepalive.
15 // This is most important for syscall.Syscall (and similar functions), so we
16 // test it explicitly.
25 func implicit(uintptr) // ERROR "assuming ~p0 is unsafe uintptr"
29 func explicit(uintptr) {
32 func autotmpImplicit() { // ERROR "can inline autotmpImplicit"
34 implicit(uintptr(unsafe.Pointer(&t))) // ERROR "live at call to implicit: .?autotmp" "stack object .autotmp_[0-9]+ unsafe.Pointer$"
37 func autotmpExplicit() { // ERROR "can inline autotmpExplicit"
39 explicit(uintptr(unsafe.Pointer(&t))) // ERROR "live at call to explicit: .?autotmp" "stack object .autotmp_[0-9]+ unsafe.Pointer$"
42 func autotmpSyscall() { // ERROR "can inline autotmpSyscall"
44 syscall.Syscall(0, 1, uintptr(unsafe.Pointer(&v)), 2) // ERROR "live at call to Syscall: .?autotmp" "stack object .autotmp_[0-9]+ unsafe.Pointer$"
47 func localImplicit() { // ERROR "can inline localImplicit"
49 p := unsafe.Pointer(&t)
50 implicit(uintptr(p)) // ERROR "live at call to implicit: .?autotmp" "stack object .autotmp_[0-9]+ unsafe.Pointer$"
53 func localExplicit() { // ERROR "can inline localExplicit"
55 p := unsafe.Pointer(&t)
56 explicit(uintptr(p)) // ERROR "live at call to explicit: .?autotmp" "stack object .autotmp_[0-9]+ unsafe.Pointer$"
59 func localSyscall() { // ERROR "can inline localSyscall"
61 p := unsafe.Pointer(&v)
62 syscall.Syscall(0, 1, uintptr(p), 2) // ERROR "live at call to Syscall: .?autotmp" "stack object .autotmp_[0-9]+ unsafe.Pointer$"