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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 700 jeremybenn
// errchk $G -e $D/$F.go
2
 
3
// Copyright 2011 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
// Issue 1708, illegal cases.
8
 
9
package p
10
 
11
func f(x int) int         { return 0 }
12
func g(x interface{}) int { return 0 }
13
func h(x float64) int     { return 0 }
14
 
15
// from the spec
16
var (
17
        s uint    = 33
18
        u         = 1.0 << s // ERROR "invalid operation|shift of non-integer operand"
19
        v float32 = 1 << s   // ERROR "invalid" "as type float32"
20
)
21
 
22
// non-constant shift expressions
23
var (
24
        e1       = g(2.0 << s) // ERROR "invalid" "as type interface"
25
        f1       = h(2 << s)   // ERROR "invalid" "as type float64"
26
        g1 int64 = 1.1 << s    // ERROR "truncated"
27
)
28
 
29
// constant shift expressions
30
const c uint = 65
31
 
32
var (
33
        a2 int = 1.0 << c    // ERROR "overflow"
34
        b2     = 1.0 << c    // ERROR "overflow"
35
        d2     = f(1.0 << c) // ERROR "overflow"
36
)

powered by: WebSVN 2.1.0

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