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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [ken/] [strvar.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
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
 
8
package main
9
 
10
type    x2      struct { a,b,c int; d int; };
11
var     g1      x2;
12
var     g2      struct { a,b,c int; d x2; };
13
 
14
func
15
main() {
16
        var x int;
17
        var s1 *x2;
18
        var s2 *struct { a,b,c int; d x2; };
19
        var s3 struct { a,b,c int; d x2; };
20
 
21
        s1 = &g1;
22
        s2 = &g2;
23
 
24
        s1.a = 1;
25
        s1.b = 2;
26
        s1.c = 3;
27
        s1.d = 5;
28
 
29
        if(s1.c != 3) { panic(s1.c); }
30
        if(g1.c != 3) { panic(g1.c); }
31
 
32
        s2.a = 7;
33
        s2.b = 11;
34
        s2.c = 13;
35
        s2.d.a = 17;
36
        s2.d.b = 19;
37
        s2.d.c = 23;
38
        s2.d.d = 29;
39
 
40
        if(s2.d.c != 23) { panic(s2.d.c); }
41
        if(g2.d.c != 23) { panic(g2.d.c); }
42
 
43
        x =     s1.a +
44
                s1.b +
45
                s1.c +
46
                s1.d +
47
 
48
                s2.a +
49
                s2.b +
50
                s2.c +
51
                s2.d.a +
52
                s2.d.b +
53
                s2.d.c +
54
                s2.d.d;
55
 
56
        if(x != 130) { panic(x); }
57
 
58
        // test an automatic struct
59
        s3.a = 7;
60
        s3.b = 11;
61
        s3.c = 13;
62
        s3.d.a = 17;
63
        s3.d.b = 19;
64
        s3.d.c = 23;
65
        s3.d.d = 29;
66
 
67
        if(s3.d.c != 23) { panic(s3.d.c); }
68
 
69
        x =     s3.a +
70
                s3.b +
71
                s3.c +
72
                s3.d.a +
73
                s3.d.b +
74
                s3.d.c +
75
                s3.d.d;
76
 
77
        if(x != 119) { panic(x); }
78
}

powered by: WebSVN 2.1.0

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