]> Cypherpunks.ru repositories - gostls13.git/blob - test/live2.go
cmd/gc: fix liveness for address-taken variables in inlined functions
[gostls13.git] / test / live2.go
1 // errorcheck -0 -live
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 type T40 struct {
16         m map[int]int
17 }
18
19 func newT40() *T40 {
20         ret := T40{ // ERROR "live at call to makemap: &ret"
21                 make(map[int]int),
22         }
23         return &ret
24 }
25
26 func bad40() {
27         t := newT40() // ERROR "live at call to makemap: ret"
28         println()     // ERROR "live at call to printnl: ret"
29         _ = t
30 }
31
32 func good40() {
33         ret := T40{ // ERROR "live at call to makemap: ret"
34                 make(map[int]int),
35         }
36         t := &ret
37         println() // ERROR "live at call to printnl: ret"
38         _ = t
39 }