1 // errorcheck -0 -m -live -std
3 //go:build !windows && !js && !wasip1
4 // +build !windows,!js,!wasip1
6 // Copyright 2015 The Go Authors. All rights reserved.
7 // Use of this source code is governed by a BSD-style
8 // license that can be found in the LICENSE file.
10 // Test escape analysis and liveness inferred for uintptrkeepalive functions.
12 // This behavior is enabled automatically for function declarations with no
13 // bodies (assembly, linkname), as well as explicitly on complete functions
14 // with //go:uintptrkeepalive.
16 // This is most important for syscall.Syscall (and similar functions), so we
17 // test it explicitly.
26 func implicit(uintptr) // ERROR "assuming ~p0 is unsafe uintptr"
30 func explicit(uintptr) {
33 func autotmpImplicit() { // ERROR "can inline autotmpImplicit"
35 implicit(uintptr(unsafe.Pointer(&t))) // ERROR "live at call to implicit: .?autotmp" "stack object .autotmp_[0-9]+ unsafe.Pointer$"
38 func autotmpExplicit() { // ERROR "can inline autotmpExplicit"
40 explicit(uintptr(unsafe.Pointer(&t))) // ERROR "live at call to explicit: .?autotmp" "stack object .autotmp_[0-9]+ unsafe.Pointer$"
43 func autotmpSyscall() { // ERROR "can inline autotmpSyscall"
45 syscall.Syscall(0, 1, uintptr(unsafe.Pointer(&v)), 2) // ERROR "live at call to Syscall: .?autotmp" "stack object .autotmp_[0-9]+ unsafe.Pointer$"
48 func localImplicit() { // ERROR "can inline localImplicit"
50 p := unsafe.Pointer(&t)
51 implicit(uintptr(p)) // ERROR "live at call to implicit: .?autotmp" "stack object .autotmp_[0-9]+ unsafe.Pointer$"
54 func localExplicit() { // ERROR "can inline localExplicit"
56 p := unsafe.Pointer(&t)
57 explicit(uintptr(p)) // ERROR "live at call to explicit: .?autotmp" "stack object .autotmp_[0-9]+ unsafe.Pointer$"
60 func localSyscall() { // ERROR "can inline localSyscall"
62 p := unsafe.Pointer(&v)
63 syscall.Syscall(0, 1, uintptr(p), 2) // ERROR "live at call to Syscall: .?autotmp" "stack object .autotmp_[0-9]+ unsafe.Pointer$"