]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/go.test/test/ken/cplx3.go
Add Go frontend, libgo library, and Go testsuite.
[thirdparty/gcc.git] / gcc / testsuite / go.test / test / ken / cplx3.go
1 // $G $D/$F.go && $L $F.$A && ./$A.out
2
3 // Copyright 2010 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 import "unsafe"
10 import "reflect"
11
12 const (
13 R = 5
14 I = 6i
15
16 C1 = R + I // ADD(5,6)
17 )
18
19 var complexBits = reflect.Typeof(complex(0i)).Size() * 8
20
21 func main() {
22 c0 := C1
23 c0 = (c0 + c0 + c0) / (c0 + c0 + 3i)
24 println(c0)
25
26 c := *(*complex)(unsafe.Pointer(&c0))
27 println(c)
28
29 println(complexBits)
30
31 var a interface{}
32 switch c := reflect.NewValue(a).(type) {
33 case *reflect.ComplexValue:
34 if complexBits == 64 {
35 v := c.Get()
36 _, _ = complex64(v), true
37 }
38 }
39 }