OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [indirect.go] - Blame information for rev 700

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 700 jeremybenn
// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG indirect
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
var m0 map[string]int
10
var m1 *map[string]int
11
var m2 *map[string]int = &m0
12
var m3 map[string]int = map[string]int{"a": 1}
13
var m4 *map[string]int = &m3
14
 
15
var s0 string
16
var s1 *string
17
var s2 *string = &s0
18
var s3 string = "a"
19
var s4 *string = &s3
20
 
21
var a0 [10]int
22
var a1 *[10]int
23
var a2 *[10]int = &a0
24
 
25
var b0 []int
26
var b1 *[]int
27
var b2 *[]int = &b0
28
var b3 []int = []int{1, 2, 3}
29
var b4 *[]int = &b3
30
 
31
func crash() {
32
        // these uses of nil pointers
33
        // would crash but should type check
34
        println("crash",
35
                len(a1)+cap(a1))
36
}
37
 
38
func nocrash() {
39
        // this is spaced funny so that
40
        // the compiler will print a different
41
        // line number for each len call if
42
        // it decides there are type errors.
43
        // it might also help in the traceback.
44
        x :=
45
                len(m0) +
46
                        len(m3)
47
        if x != 1 {
48
                println("wrong maplen")
49
                panic("fail")
50
        }
51
 
52
        x =
53
                len(s0) +
54
                        len(s3)
55
        if x != 1 {
56
                println("wrong stringlen")
57
                panic("fail")
58
        }
59
 
60
        x =
61
                len(a0) +
62
                        len(a2)
63
        if x != 20 {
64
                println("wrong arraylen")
65
                panic("fail")
66
        }
67
 
68
        x =
69
                len(b0) +
70
                        len(b3)
71
        if x != 3 {
72
                println("wrong slicelen")
73
                panic("fail")
74
        }
75
 
76
        x =
77
                cap(b0) +
78
                        cap(b3)
79
        if x != 3 {
80
                println("wrong slicecap")
81
                panic("fail")
82
        }
83
}
84
 
85
func main() { nocrash() }

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.