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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [fixedbugs/] [bug260.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: bug260 failed
2
 
3
// Test that structures pack densely, according to the alignment of the largest field.
4
 
5
package main
6
 
7
import (
8
        "fmt"
9
        "os"
10
        "strconv"
11
)
12
 
13
type T1 struct {
14
        x uint8
15
}
16
type T2 struct {
17
        x uint16
18
}
19
type T4 struct {
20
        x uint32
21
}
22
 
23
func main() {
24
        report := len(os.Args) > 1
25
        status := 0
26
        var b1 [10]T1
27
        a0, _ := strconv.ParseUint(fmt.Sprintf("%p", &b1[0])[2:], 16, 64)
28
        a1, _ := strconv.ParseUint(fmt.Sprintf("%p", &b1[1])[2:], 16, 64)
29
        if a1 != a0+1 {
30
                fmt.Println("FAIL")
31
                if report {
32
                        fmt.Println("alignment should be 1, is", a1-a0)
33
                }
34
                status = 1
35
        }
36
        var b2 [10]T2
37
        a0, _ = strconv.ParseUint(fmt.Sprintf("%p", &b2[0])[2:], 16, 64)
38
        a1, _ = strconv.ParseUint(fmt.Sprintf("%p", &b2[1])[2:], 16, 64)
39
        if a1 != a0+2 {
40
                if status == 0 {
41
                        fmt.Println("FAIL")
42
                        status = 1
43
                }
44
                if report {
45
                        fmt.Println("alignment should be 2, is", a1-a0)
46
                }
47
        }
48
        var b4 [10]T4
49
        a0, _ = strconv.ParseUint(fmt.Sprintf("%p", &b4[0])[2:], 16, 64)
50
        a1, _ = strconv.ParseUint(fmt.Sprintf("%p", &b4[1])[2:], 16, 64)
51
        if a1 != a0+4 {
52
                if status == 0 {
53
                        fmt.Println("FAIL")
54
                        status = 1
55
                }
56
                if report {
57
                        fmt.Println("alignment should be 4, is", a1-a0)
58
                }
59
        }
60
        os.Exit(status)
61
}

powered by: WebSVN 2.1.0

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