modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/live2.go (about) 1 // errorcheck -0 -live -wb=0 2 3 // Copyright 2014 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 // liveness tests with inlining ENABLED 8 // see also live.go. 9 10 package main 11 12 // issue 8142: lost 'addrtaken' bit on inlined variables. 13 // no inlining in this test, so just checking that non-inlined works. 14 15 func printnl() 16 17 //go:noescape 18 func useT40(*T40) 19 20 type T40 struct { 21 m map[int]int 22 } 23 24 func newT40() *T40 { 25 ret := T40{} 26 ret.m = make(map[int]int, 42) // ERROR "live at call to makemap: &ret$" 27 return &ret 28 } 29 30 func bad40() { 31 t := newT40() // ERROR "live at call to makemap: .autotmp_[0-9]+ ret$" 32 printnl() // ERROR "live at call to printnl: .autotmp_[0-9]+ ret$" 33 useT40(t) // ERROR "live at call to useT40: .autotmp_[0-9]+ ret$" 34 } 35 36 func good40() { 37 ret := T40{} 38 ret.m = make(map[int]int, 42) // ERROR "live at call to makemap: .autotmp_[0-9]+ ret$" 39 t := &ret 40 printnl() // ERROR "live at call to printnl: .autotmp_[0-9]+ ret$" 41 useT40(t) // ERROR "live at call to useT40: .autotmp_[0-9]+ ret$" 42 }