URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [fixedbugs/] [bug284.go] - Rev 700
Compare with Previous | Blame | View Log
// errchk $G -e $D/$F.go// Copyright 2010 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.// Test cases for revised conversion rules.package mainfunc main() {type NewInt inti0 := 0var i1 int = 1var i2 NewInt = 1i0 = i0i0 = i1i0 = int(i2)i1 = i0i1 = i1i1 = int(i2)i2 = NewInt(i0)i2 = NewInt(i1)i2 = i2type A1 [3]inttype A2 [3]NewIntvar a0 [3]intvar a1 A1var a2 A2a0 = a0a0 = a1a0 = [3]int(a2) // ERROR "cannot|invalid"a1 = a0a1 = a1a1 = A1(a2) // ERROR "cannot|invalid"a2 = A2(a0) // ERROR "cannot|invalid"a2 = A2(a1) // ERROR "cannot|invalid"a2 = a2type S1 struct {x int}type S2 struct {x NewInt}var s0 struct {x int}var s1 S1var s2 S2s0 = s0s0 = s1s0 = struct {x int}(s2) // ERROR "cannot|invalid"s1 = s0s1 = s1s1 = S1(s2) // ERROR "cannot|invalid"s2 = S2(s0) // ERROR "cannot|invalid"s2 = S2(s1) // ERROR "cannot|invalid"s2 = s2type P1 *inttype P2 *NewIntvar p0 *intvar p1 P1var p2 P2p0 = p0p0 = p1p0 = (*int)(p2) // ERROR "cannot|invalid"p1 = p0p1 = p1p1 = P1(p2) // ERROR "cannot|invalid"p2 = P2(p0) // ERROR "cannot|invalid"p2 = P2(p1) // ERROR "cannot|invalid"p2 = p2type Q1 *struct {x int}type Q2 *S1var q0 *struct {x int}var q1 Q1var q2 Q2var ps1 *S1q0 = q0q0 = q1q0 = (*struct {x int})(ps1) // legal because of special conversion exception for pointersq0 = (*struct {x int})(q2) // ERROR "cannot|invalid"q1 = q0q1 = q1q1 = Q1(q2) // ERROR "cannot|invalid"q2 = (*S1)(q0) // legal because of special conversion exception for pointersq2 = Q2(q1) // ERROR "cannot|invalid"q2 = q2type F1 func(x NewInt) inttype F2 func(x int) NewIntvar f0 func(x NewInt) intvar f1 F1var f2 F2f0 = f0f0 = f1f0 = func(x NewInt) int(f2) // ERROR "cannot|invalid"f1 = f0f1 = f1f1 = F1(f2) // ERROR "cannot|invalid"f2 = F2(f0) // ERROR "cannot|invalid"f2 = F2(f1) // ERROR "cannot|invalid"f2 = f2type X1 interface {f() int}type X2 interface {f() NewInt}var x0 interface {f() int}var x1 X1var x2 X2x0 = x0x0 = x1x0 = interface {f() int}(x2) // ERROR "cannot|need type assertion|incompatible"x1 = x0x1 = x1x1 = X1(x2) // ERROR "cannot|need type assertion|incompatible"x2 = X2(x0) // ERROR "cannot|need type assertion|incompatible"x2 = X2(x1) // ERROR "cannot|need type assertion|incompatible"x2 = x2type L1 []inttype L2 []NewIntvar l0 []intvar l1 L1var l2 L2l0 = l0l0 = l1l0 = []int(l2) // ERROR "cannot|invalid"l1 = l0l1 = l1l1 = L1(l2) // ERROR "cannot|invalid"l2 = L2(l0) // ERROR "cannot|invalid"l2 = L2(l1) // ERROR "cannot|invalid"l2 = l2type M1 map[string]inttype M2 map[string]NewIntvar m0 []intvar m1 L1var m2 L2m0 = m0m0 = m1m0 = []int(m2) // ERROR "cannot|invalid"m1 = m0m1 = m1m1 = L1(m2) // ERROR "cannot|invalid"m2 = L2(m0) // ERROR "cannot|invalid"m2 = L2(m1) // ERROR "cannot|invalid"m2 = m2type C1 chan inttype C2 chan NewIntvar c0 chan intvar c1 C1var c2 C2c0 = c0c0 = c1c0 = chan int(c2) // ERROR "cannot|invalid"c1 = c0c1 = c1c1 = C1(c2) // ERROR "cannot|invalid"c2 = C2(c0) // ERROR "cannot|invalid"c2 = C2(c1) // ERROR "cannot|invalid"c2 = c2// internal compiler error (6g and gccgo)type T interface{}var _ T = 17 // assignment compatible_ = T(17) // internal compiler error even though assignment compatible}
