Merge from trunk
[official-gcc.git] / gcc / testsuite / go.test / test / escape3.go
blob4c1989151465d0f69eefb41aa20a590e72715ab4
1 // run
3 // Copyright 2011 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.
7 // Test the run-time behavior of escape analysis-related optimizations.
9 package main
11 func main() {
12 test1()
15 func test1() {
16 check1(0)
17 check1(1)
18 check1(2)
21 type T1 struct {
22 X, Y, Z int
25 func f() int {
26 return 1
29 func check1(pass int) T1 {
30 v := []T1{{X: f(), Z: f()}}
31 if v[0].Y != 0 {
32 panic("nonzero init")
34 v[0].Y = pass
35 return v[0]