blob: cc1b0b7acf580cb1902c71ee143b658b747bd255 [file] [log] [blame]
Russ Coxfcb4cab2014-09-11 12:17:45 -04001// errorcheck -0 -live -wb=0
Russ Coxeb540792014-06-02 21:26:32 -04002
Emmanuel Odeke53fd5222016-04-10 14:32:26 -07003// Copyright 2014 The Go Authors. All rights reserved.
Russ Coxeb540792014-06-02 21:26:32 -04004// 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
10package 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
Russ Cox75d3f622014-11-05 14:42:54 -050015func printnl()
16
Michael Munday744ebfd2017-03-29 14:01:41 -040017//go:noescape
18func useT40(*T40)
19
Russ Coxeb540792014-06-02 21:26:32 -040020type T40 struct {
21 m map[int]int
22}
23
24func newT40() *T40 {
Russ Cox454d1b02014-09-30 12:48:47 -040025 ret := T40{}
Martin Möhrmannfbfc2032017-09-02 18:46:59 +020026 ret.m = make(map[int]int, 42) // ERROR "live at call to makemap: &ret$"
Russ Coxeb540792014-06-02 21:26:32 -040027 return &ret
28}
29
30func bad40() {
David Chase9c066ba2016-10-28 13:33:57 -040031 t := newT40() // ERROR "live at call to makemap: .autotmp_[0-9]+ ret$"
32 printnl() // ERROR "live at call to printnl: .autotmp_[0-9]+ ret$"
Michael Munday744ebfd2017-03-29 14:01:41 -040033 useT40(t) // ERROR "live at call to useT40: .autotmp_[0-9]+ ret$"
Russ Coxeb540792014-06-02 21:26:32 -040034}
35
36func good40() {
Russ Cox454d1b02014-09-30 12:48:47 -040037 ret := T40{}
Martin Möhrmannfbfc2032017-09-02 18:46:59 +020038 ret.m = make(map[int]int, 42) // ERROR "live at call to makemap: .autotmp_[0-9]+ ret$"
Russ Coxeb540792014-06-02 21:26:32 -040039 t := &ret
David Chase9c066ba2016-10-28 13:33:57 -040040 printnl() // ERROR "live at call to printnl: .autotmp_[0-9]+ ret$"
Michael Munday744ebfd2017-03-29 14:01:41 -040041 useT40(t) // ERROR "live at call to useT40: .autotmp_[0-9]+ ret$"
Russ Coxeb540792014-06-02 21:26:32 -040042}