PR middle-end/77674
[official-gcc.git] / gcc / testsuite / go.test / test / convert.go
blob7280edf333cdc841b3d762d68a5684b66f6a0c3d
1 // run
3 // Copyright 2009 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 types of constant expressions, using reflect.
9 package main
11 import "reflect"
13 func typeof(x interface{}) string { return reflect.TypeOf(x).String() }
15 func f() int { return 0 }
17 func g() int { return 0 }
19 type T func() int
21 var m = map[string]T{"f": f}
23 type A int
24 type B int
26 var a A = 1
27 var b B = 2
28 var x int
30 func main() {
31 want := typeof(g)
32 if t := typeof(f); t != want {
33 println("type of f is", t, "want", want)
34 panic("fail")
37 want = typeof(a)
38 if t := typeof(+a); t != want {
39 println("type of +a is", t, "want", want)
40 panic("fail")
42 if t := typeof(a + 0); t != want {
43 println("type of a+0 is", t, "want", want)
44 panic("fail")