LEFT | RIGHT |
(no file at all) | |
1 // errorcheck -0 -live -wb=0 | 1 // errorcheck -0 -live -wb=0 |
2 | 2 |
3 // Copyright 2014 The Go Authors. All rights reserved. | 3 // Copyright 2014 The Go Authors. All rights reserved. |
4 // Use of this source code is governed by a BSD-style | 4 // Use of this source code is governed by a BSD-style |
5 // license that can be found in the LICENSE file. | 5 // license that can be found in the LICENSE file. |
6 | 6 |
7 // liveness tests with inlining ENABLED | 7 // liveness tests with inlining ENABLED |
8 // see also live.go. | 8 // see also live.go. |
9 | 9 |
10 package main | 10 package main |
11 | 11 |
12 // issue 8142: lost 'addrtaken' bit on inlined variables. | 12 // issue 8142: lost 'addrtaken' bit on inlined variables. |
13 // no inlining in this test, so just checking that non-inlined works. | 13 // no inlining in this test, so just checking that non-inlined works. |
14 | 14 |
| 15 func printnl() |
| 16 |
15 type T40 struct { | 17 type T40 struct { |
16 m map[int]int | 18 m map[int]int |
17 } | 19 } |
18 | 20 |
19 func newT40() *T40 { | 21 func newT40() *T40 { |
20 ret := T40{} | 22 ret := T40{} |
21 ret.m = make(map[int]int) // ERROR "live at call to makemap: &ret" | 23 ret.m = make(map[int]int) // ERROR "live at call to makemap: &ret" |
22 return &ret | 24 return &ret |
23 } | 25 } |
24 | 26 |
25 func bad40() { | 27 func bad40() { |
26 t := newT40() // ERROR "live at call to makemap: ret" | 28 t := newT40() // ERROR "live at call to makemap: ret" |
27 » println() // ERROR "live at call to printnl: ret" | 29 » printnl() // ERROR "live at call to printnl: ret" |
28 _ = t | 30 _ = t |
29 } | 31 } |
30 | 32 |
31 func good40() { | 33 func good40() { |
32 ret := T40{} | 34 ret := T40{} |
33 ret.m = make(map[int]int) // ERROR "live at call to makemap: ret" | 35 ret.m = make(map[int]int) // ERROR "live at call to makemap: ret" |
34 t := &ret | 36 t := &ret |
35 » println() // ERROR "live at call to printnl: ret" | 37 » printnl() // ERROR "live at call to printnl: ret" |
36 _ = t | 38 _ = t |
37 } | 39 } |
LEFT | RIGHT |