testsuite: fix c23-constexpr-2a.c test to use dg-do run
[official-gcc.git] / gcc / testsuite / go.test / test / named1.go
blob7feae13b9d7045f9cd405ad13dbc559df56a7695
1 // errorcheck
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.
7 // Test that basic operations on named types are valid
8 // and preserve the type.
9 // Does not compile.
11 package main
13 type Bool bool
15 type Map map[int]int
17 func (Map) M() {}
19 type Slice []byte
21 var slice Slice
23 func asBool(Bool) {}
24 func asString(String) {}
26 type String string
28 func main() {
29 var (
30 b Bool = true
31 i, j int
32 c = make(chan int)
33 m = make(Map)
36 asBool(b)
37 asBool(!b)
38 asBool(true)
39 asBool(*&b)
40 asBool(Bool(true))
41 asBool(1 != 2) // ok now
42 asBool(i < j) // ok now
44 _, b = m[2] // ok now
46 var inter interface{}
47 _, b = inter.(Map) // ok now
48 _ = b
50 var minter interface {
51 M()
53 _, b = minter.(Map) // ok now
54 _ = b
56 _, bb := <-c
57 asBool(bb) // ERROR "cannot use.*type bool.*as type Bool"
58 _, b = <-c // ok now
59 _ = b
61 asString(String(slice)) // ok