OSDN Git Service

59471388c069531a119183abcba147644194ec1d
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / go.test / test / assign.go
1 // errchk $G -e $D/$F.go
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 import "sync"
10
11 type T struct {
12         int
13         sync.Mutex
14 }
15
16 func main() {
17         {
18                 var x, y sync.Mutex
19                 x = y   // ERROR "assignment.*Mutex"
20                 _ = x
21         }
22         {
23                 var x, y T
24                 x = y   // ERROR "assignment.*Mutex"
25                 _ = x
26         }
27         {
28                 var x, y [2]sync.Mutex
29                 x = y   // ERROR "assignment.*Mutex"
30                 _ = x
31         }
32         {
33                 var x, y [2]T
34                 x = y   // ERROR "assignment.*Mutex"
35                 _ = x
36         }
37         {
38                 x := sync.Mutex{0, 0}   // ERROR "assignment.*Mutex"
39                 _ = x
40         }
41         {
42                 x := sync.Mutex{key: 0} // ERROR "(unknown|assignment).*Mutex"
43                 _ = x
44         }
45         {
46                 x := &sync.Mutex{}      // ok
47                 var y sync.Mutex        // ok
48                 y = *x  // ERROR "assignment.*Mutex"
49                 *x = y  // ERROR "assignment.*Mutex"
50                 _ = x
51                 _ = y
52         }               
53 }