blob: f1131a268845582d37dab792a10c7fbf90b37d83 [file] [log] [blame]
Russ Cox0b477ef2012-02-16 23:48:57 -05001// run
Russ Coxc45c0c02011-09-02 15:11:28 -04002
Emmanuel Odeke53fd5222016-04-10 14:32:26 -07003// Copyright 2011 The Go Authors. All rights reserved.
Russ Coxc45c0c02011-09-02 15:11:28 -04004// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file.
6
Rob Pike83976e32012-02-19 14:28:53 +11007// Test the run-time behavior of escape analysis-related optimizations.
Russ Coxc45c0c02011-09-02 15:11:28 -04008
9package main
10
11func main() {
12 test1()
13}
14
15func test1() {
16 check1(0)
17 check1(1)
18 check1(2)
19}
20
21type T1 struct {
22 X, Y, Z int
23}
24
25func f() int {
26 return 1
27}
28
29func check1(pass int) T1 {
30 v := []T1{{X: f(), Z: f()}}
31 if v[0].Y != 0 {
32 panic("nonzero init")
33 }
34 v[0].Y = pass
35 return v[0]
36}