blob: 747475615703bd503067240c0acf5a3915966825 [file] [log] [blame]
Russ Coxfcb4cab2014-09-11 12:17:45 -04001// errorcheck -0 -live -wb=0
Russ Coxeb540792014-06-02 21:26:32 -04002
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
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
Russ Coxeb540792014-06-02 21:26:32 -040017type T40 struct {
18 m map[int]int
19}
20
21func newT40() *T40 {
Russ Cox454d1b02014-09-30 12:48:47 -040022 ret := T40{}
23 ret.m = make(map[int]int) // ERROR "live at call to makemap: &ret"
Russ Coxeb540792014-06-02 21:26:32 -040024 return &ret
25}
26
27func bad40() {
Dmitry Vyukovb3be3602015-01-29 19:40:02 +030028 t := newT40() // ERROR "live at call to makemap: autotmp_.* ret"
29 printnl() // ERROR "live at call to printnl: autotmp_.* ret"
Russ Coxeb540792014-06-02 21:26:32 -040030 _ = t
31}
32
33func good40() {
Russ Cox454d1b02014-09-30 12:48:47 -040034 ret := T40{}
Dmitry Vyukovb3be3602015-01-29 19:40:02 +030035 ret.m = make(map[int]int) // ERROR "live at call to makemap: autotmp_.* ret"
Russ Coxeb540792014-06-02 21:26:32 -040036 t := &ret
Dmitry Vyukovb3be3602015-01-29 19:40:02 +030037 printnl() // ERROR "live at call to printnl: autotmp_.* ret"
Russ Coxeb540792014-06-02 21:26:32 -040038 _ = t
39}