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 | |
Emmanuel Odeke | 53fd522 | 2016-04-10 14:32:26 -0700 | [diff] [blame] | 3 | // Copyright 2014 The Go Authors. All rights reserved. |
Russ Cox | eb54079 | 2014-06-02 21:26:32 -0400 | [diff] [blame] | 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 | |
Michael Munday | 744ebfd | 2017-03-29 14:01:41 -0400 | [diff] [blame] | 17 | //go:noescape |
| 18 | func useT40(*T40) |
| 19 | |
Russ Cox | eb54079 | 2014-06-02 21:26:32 -0400 | [diff] [blame] | 20 | type T40 struct { |
| 21 | m map[int]int |
| 22 | } |
| 23 | |
| 24 | func newT40() *T40 { |
Russ Cox | 454d1b0 | 2014-09-30 12:48:47 -0400 | [diff] [blame] | 25 | ret := T40{} |
Martin Möhrmann | fbfc203 | 2017-09-02 18:46:59 +0200 | [diff] [blame] | 26 | ret.m = make(map[int]int, 42) // ERROR "live at call to makemap: &ret$" |
Russ Cox | eb54079 | 2014-06-02 21:26:32 -0400 | [diff] [blame] | 27 | return &ret |
| 28 | } |
| 29 | |
| 30 | func bad40() { |
David Chase | 9c066ba | 2016-10-28 13:33:57 -0400 | [diff] [blame] | 31 | 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 Munday | 744ebfd | 2017-03-29 14:01:41 -0400 | [diff] [blame] | 33 | useT40(t) // ERROR "live at call to useT40: .autotmp_[0-9]+ ret$" |
Russ Cox | eb54079 | 2014-06-02 21:26:32 -0400 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | func good40() { |
Russ Cox | 454d1b0 | 2014-09-30 12:48:47 -0400 | [diff] [blame] | 37 | ret := T40{} |
Martin Möhrmann | fbfc203 | 2017-09-02 18:46:59 +0200 | [diff] [blame] | 38 | ret.m = make(map[int]int, 42) // ERROR "live at call to makemap: .autotmp_[0-9]+ ret$" |
Russ Cox | eb54079 | 2014-06-02 21:26:32 -0400 | [diff] [blame] | 39 | t := &ret |
David Chase | 9c066ba | 2016-10-28 13:33:57 -0400 | [diff] [blame] | 40 | printnl() // ERROR "live at call to printnl: .autotmp_[0-9]+ ret$" |
Michael Munday | 744ebfd | 2017-03-29 14:01:41 -0400 | [diff] [blame] | 41 | useT40(t) // ERROR "live at call to useT40: .autotmp_[0-9]+ ret$" |
Russ Cox | eb54079 | 2014-06-02 21:26:32 -0400 | [diff] [blame] | 42 | } |