1// errorcheck -0 -d=checkptr -m 2 3// Copyright 2020 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 that we can inline the receiver arguments for 8// reflect.Value.UnsafeAddr/Pointer, even in checkptr mode. 9 10package main 11 12import ( 13 "reflect" 14 "unsafe" 15) 16 17func main() { 18 n := 10 // ERROR "moved to heap: n" 19 m := make(map[string]string) // ERROR "moved to heap: m" "make\(map\[string\]string\) escapes to heap" 20 21 _ = unsafe.Pointer(reflect.ValueOf(&n).Elem().UnsafeAddr()) // ERROR "inlining call" 22 _ = unsafe.Pointer(reflect.ValueOf(&m).Elem().Pointer()) // ERROR "inlining call" 23} 24