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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 700 jeremybenn
// errchk $G -e $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
package main
8
 
9
type I interface{}
10
 
11
const (
12
        // assume all types behave similarly to int8/uint8
13
        Int8   int8  = 101
14
        Minus1 int8  = -1
15
        Uint8  uint8 = 102
16
        Const  = 103
17
 
18
        Float32    float32 = 104.5
19
        Float64    float64 = 105.5
20
        ConstFloat = 106.5
21
        Big        float64 = 1e300
22
 
23
        String = "abc"
24
        Bool   = true
25
)
26
 
27
var (
28
        a1 = Int8 * 100              // ERROR "overflow"
29
        a2 = Int8 * -1               // OK
30
        a3 = Int8 * 1000             // ERROR "overflow"
31
        a4 = Int8 * int8(1000)       // ERROR "overflow"
32
        a5 = int8(Int8 * 1000)       // ERROR "overflow"
33
        a6 = int8(Int8 * int8(1000)) // ERROR "overflow"
34
        a7 = Int8 - 2*Int8 - 2*Int8  // ERROR "overflow"
35
        a8 = Int8 * Const / 100      // ERROR "overflow"
36
        a9 = Int8 * (Const / 100)    // OK
37
 
38
        b1   = Uint8 * Uint8                                 // ERROR "overflow"
39
        b2   = Uint8 * -1                                    // ERROR "overflow"
40
        b3   = Uint8 - Uint8                                 // OK
41
        b4   = Uint8 - Uint8 - Uint8                         // ERROR "overflow"
42
        b5   = uint8(^0)                                     // ERROR "overflow"
43
        b6   = ^uint8(0)                                     // OK
44
        b7   = uint8(Minus1)                                 // ERROR "overflow"
45
        b8   = uint8(int8(-1))                               // ERROR "overflow"
46
        b8a  = uint8(-1)                                     // ERROR "overflow"
47
        b9   byte                    = (1 << 10) >> 8        // OK
48
        b10  byte                    = (1 << 10)             // ERROR "overflow"
49
        b11  byte                    = (byte(1) << 10) >> 8  // ERROR "overflow"
50
        b12  byte                    = 1000                  // ERROR "overflow"
51
        b13  byte                    = byte(1000)            // ERROR "overflow"
52
        b14  byte                    = byte(100) * byte(100) // ERROR "overflow"
53
        b15  byte                    = byte(100) * 100       // ERROR "overflow"
54
        b16  byte                    = byte(0) * 1000        // ERROR "overflow"
55
        b16a byte                    = 0 * 1000              // OK
56
        b17  byte                    = byte(0) * byte(1000)  // ERROR "overflow"
57
        b18  byte                    = Uint8 / 0             // ERROR "division by zero"
58
 
59
        c1 float64     = Big
60
        c2 float64     = Big * Big          // ERROR "overflow"
61
        c3 float64     = float64(Big) * Big // ERROR "overflow"
62
        c4 = Big * Big                      // ERROR "overflow"
63
        c5 = Big / 0                        // ERROR "division by zero"
64
)
65
 
66
func f(int)
67
 
68
func main() {
69
        f(Int8)             // ERROR "convert|wrong type|cannot"
70
        f(Minus1)           // ERROR "convert|wrong type|cannot"
71
        f(Uint8)            // ERROR "convert|wrong type|cannot"
72
        f(Const)            // OK
73
        f(Float32)          // ERROR "convert|wrong type|cannot"
74
        f(Float64)          // ERROR "convert|wrong type|cannot"
75
        f(ConstFloat)       // ERROR "truncate"
76
        f(ConstFloat - 0.5) // OK
77
        f(Big)              // ERROR "convert|wrong type|cannot"
78
        f(String)           // ERROR "convert|wrong type|cannot|incompatible"
79
        f(Bool)             // ERROR "convert|wrong type|cannot|incompatible"
80
}
81
 
82
const ptr = nil // ERROR "const.*nil"

powered by: WebSVN 2.1.0

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