Commit 373f1a95 authored by Ian Lance Taylor's avatar Ian Lance Taylor

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

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5971044
parent c24daa22
......@@ -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")
......
// 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()
}
// 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)
// 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{}
// 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)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment