OSDN Git Service

PR go/50656
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / go.test / test / fixedbugs / bug329.go
1 // $G $D/$F.go && $L $F.$A && ./$A.out
2
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.
6
7 package main
8
9 type Value struct {
10         X interface{}
11         Y int
12 }
13
14 type Struct struct {
15         X complex128
16 }
17
18 const magic = 1 + 2i
19
20 func (Value) Complex(x complex128) {
21         if x != magic {
22                 println(x)
23                 panic("bad complex magic")
24         }
25 }
26
27 func f(x *byte, y, z int) complex128 {
28         return magic
29 }
30
31 func (Value) Struct(x Struct) {
32         if x.X != magic {
33                 println(x.X)
34                 panic("bad struct magic")
35         }
36 }
37
38 func f1(x *byte, y, z int) Struct {
39         return Struct{magic}
40 }
41
42 func main() {
43         var v Value
44         v.Struct(f1(nil, 0, 0)) // ok
45         v.Complex(f(nil, 0, 0)) // used to fail
46 }