test: add some tests of valid code that failed with gccgo

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5971044
This commit is contained in:
Ian Lance Taylor 2012-03-30 08:42:21 -07:00
parent c24daa222f
commit 373f1a95b0
5 changed files with 93 additions and 1 deletions

View file

@ -113,7 +113,7 @@ type I interface {
type TI struct{}
func (TI) M(x int, y int) {
func (_ TI) M(x int, y int) {
if x != y {
println("invalid M call:", x, y)
panic("bad M")

22
test/fixedbugs/bug430.go Normal file
View file

@ -0,0 +1,22 @@
// compile
// Copyright 2012 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.
// gccgo crashed compiling this.
package main
type S struct {
f [2][]int
}
func F() (r [2][]int) {
return
}
func main() {
var a []S
a[0].f = F()
}

18
test/fixedbugs/bug431.go Normal file
View file

@ -0,0 +1,18 @@
// compile
// Copyright 2012 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.
// gccgo gave an invalid error ("floating point constant truncated to
// integer") compiling this.
package p
const C = 1<<63 - 1
func F(i int64) int64 {
return i
}
var V = F(int64(C) / 1e6)

13
test/fixedbugs/bug432.go Normal file
View file

@ -0,0 +1,13 @@
// compile
// Copyright 2012 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.
// gccgo crashed compiling this.
package p
var v struct{ I }
type I interface{}

39
test/fixedbugs/bug433.go Normal file
View file

@ -0,0 +1,39 @@
// run
// Copyright 2012 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 that initializing struct fields out of order still runs
// functions in the right order. This failed with gccgo.
package main
type S struct {
i1, i2, i3 int
}
var G int
func v(i int) int {
if i != G {
panic(i)
}
G = i + 1
return G
}
func F() S {
return S{
i1: v(0),
i3: v(1),
i2: v(2),
}
}
func main() {
s := F()
if s != (S{1, 3, 2}) {
panic(s)
}
}