]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/go.test/test/ken/ptrfun.go
Add Go frontend, libgo library, and Go testsuite.
[thirdparty/gcc.git] / gcc / testsuite / go.test / test / ken / ptrfun.go
1 // $G $D/$F.go && $L $F.$A && ./$A.out
2
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.
6
7
8 package main
9
10 type C struct {
11 a int;
12 x func(p *C)int;
13 }
14
15 func (this *C) f()int {
16 return this.a;
17 }
18
19 func
20 main() {
21 var v int;
22 var c *C;
23
24 c = new(C);
25 c.a = 6;
26 c.x = g;
27
28 v = g(c);
29 if v != 6 { panic(v); }
30
31 v = c.x(c);
32 if v != 6 { panic(v); }
33
34 v = c.f();
35 if v != 6 { panic(v); }
36 }
37
38 func g(p *C)int {
39 var v int;
40
41 v = p.a;
42 if v != 6 { panic(v); }
43 return p.a;
44 }