]> Cypherpunks.ru repositories - gostls13.git/commitdiff
test: add some tests of valid code that failed with gccgo
authorIan Lance Taylor <iant@golang.org>
Fri, 30 Mar 2012 15:42:21 +0000 (08:42 -0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 30 Mar 2012 15:42:21 +0000 (08:42 -0700)
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5971044

test/blank.go
test/fixedbugs/bug430.go [new file with mode: 0644]
test/fixedbugs/bug431.go [new file with mode: 0644]
test/fixedbugs/bug432.go [new file with mode: 0644]
test/fixedbugs/bug433.go [new file with mode: 0644]

index 961ed153bb8f493b13b4ed533484b39014977f34..ee618b148585675d8c52ae1652c2af63f73d767c 100644 (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")
diff --git a/test/fixedbugs/bug430.go b/test/fixedbugs/bug430.go
new file mode 100644 (file)
index 0000000..93d5cf2
--- /dev/null
@@ -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()
+}
diff --git a/test/fixedbugs/bug431.go b/test/fixedbugs/bug431.go
new file mode 100644 (file)
index 0000000..1057dad
--- /dev/null
@@ -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)
diff --git a/test/fixedbugs/bug432.go b/test/fixedbugs/bug432.go
new file mode 100644 (file)
index 0000000..0c1a914
--- /dev/null
@@ -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{}
diff --git a/test/fixedbugs/bug433.go b/test/fixedbugs/bug433.go
new file mode 100644 (file)
index 0000000..1139dfa
--- /dev/null
@@ -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)
+       }
+}