]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/go.test/test/test0.go
Add Go frontend, libgo library, and Go testsuite.
[thirdparty/gcc.git] / gcc / testsuite / go.test / test / test0.go
1 // $G $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 package main
8
9 const
10 a_const = 0
11
12 const (
13 pi = /* the usual */ 3.14159265358979323
14 e = 2.718281828
15 mask1 int = 1 << iota
16 mask2 = 1 << iota
17 mask3 = 1 << iota
18 mask4 = 1 << iota
19 )
20
21 type (
22 Empty interface {}
23 Point struct {
24 x, y int
25 }
26 Point2 Point
27 )
28
29 func (p *Point) Initialize(x, y int) *Point {
30 p.x, p.y = x, y
31 return p
32 }
33
34 func (p *Point) Distance() int {
35 return p.x * p.x + p.y * p.y
36 }
37
38 var (
39 x1 int
40 x2 int
41 u, v, w float
42 )
43
44 func foo() {}
45
46 func min(x, y int) int {
47 if x < y { return x; }
48 return y
49 }
50
51 func swap(x, y int) (u, v int) {
52 u = y
53 v = x
54 return
55 }
56
57 func control_structs() {
58 var p *Point = new(Point).Initialize(2, 3)
59 i := p.Distance()
60 var f float = 0.3
61 _ = f
62 for {}
63 for {}
64 for j := 0; j < i; j++ {
65 if i == 0 {
66 } else i = 0
67 var x float
68 _ = x
69 }
70 foo: // a label
71 var j int
72 switch y := 0; true {
73 case i < y:
74 fallthrough
75 case i < j:
76 case i == 0, i == 1, i == j:
77 i++; i++
78 goto foo
79 default:
80 i = -+-+i
81 break
82 }
83 }
84
85 func main() {
86 }