OSDN Git Service

Update to current version of Go library.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / go.test / test / interface / pointer.go
1 // errchk $G $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 // Check that interface{M()} = *interface{M()} produces a compiler error.
8
9 package main
10
11 type Inst interface {
12         Next() *Inst
13 }
14
15 type Regexp struct {
16         code  []Inst
17         start Inst
18 }
19
20 type Start struct {
21         foo *Inst
22 }
23
24 func (start *Start) Next() *Inst { return nil }
25
26
27 func AddInst(Inst) *Inst {
28         print("ok in addinst\n")
29         return nil
30 }
31
32 func main() {
33         print("call addinst\n")
34         var x Inst = AddInst(new(Start)) // ERROR "pointer to interface"
35         print("return from  addinst\n")
36 }