Russ Cox | fcb4cab | 2014-09-11 12:17:45 -0400 | [diff] [blame] | 1 | // errorcheck -0 -live -wb=0 |
Russ Cox | eb54079 | 2014-06-02 21:26:32 -0400 | [diff] [blame] | 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 | |
Russ Cox | 75d3f62 | 2014-11-05 14:42:54 -0500 | [diff] [blame] | 15 | func printnl() |
| 16 | |
Russ Cox | eb54079 | 2014-06-02 21:26:32 -0400 | [diff] [blame] | 17 | type T40 struct { |
| 18 | m map[int]int |
| 19 | } |
| 20 | |
| 21 | func newT40() *T40 { |
Russ Cox | 454d1b0 | 2014-09-30 12:48:47 -0400 | [diff] [blame] | 22 | ret := T40{} |
| 23 | ret.m = make(map[int]int) // ERROR "live at call to makemap: &ret" |
Russ Cox | eb54079 | 2014-06-02 21:26:32 -0400 | [diff] [blame] | 24 | return &ret |
| 25 | } |
| 26 | |
| 27 | func bad40() { |
Dmitry Vyukov | b3be360 | 2015-01-29 19:40:02 +0300 | [diff] [blame] | 28 | t := newT40() // ERROR "live at call to makemap: autotmp_.* ret" |
| 29 | printnl() // ERROR "live at call to printnl: autotmp_.* ret" |
Russ Cox | eb54079 | 2014-06-02 21:26:32 -0400 | [diff] [blame] | 30 | _ = t |
| 31 | } |
| 32 | |
| 33 | func good40() { |
Russ Cox | 454d1b0 | 2014-09-30 12:48:47 -0400 | [diff] [blame] | 34 | ret := T40{} |
Dmitry Vyukov | b3be360 | 2015-01-29 19:40:02 +0300 | [diff] [blame] | 35 | ret.m = make(map[int]int) // ERROR "live at call to makemap: autotmp_.* ret" |
Russ Cox | eb54079 | 2014-06-02 21:26:32 -0400 | [diff] [blame] | 36 | t := &ret |
Dmitry Vyukov | b3be360 | 2015-01-29 19:40:02 +0300 | [diff] [blame] | 37 | printnl() // ERROR "live at call to printnl: autotmp_.* ret" |
Russ Cox | eb54079 | 2014-06-02 21:26:32 -0400 | [diff] [blame] | 38 | _ = t |
| 39 | } |