OSDN Git Service

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