summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2012-03-30 08:42:21 -0700
committerIan Lance Taylor <iant@golang.org>2012-03-30 08:42:21 -0700
commit71dc56dbff5b5c418202788f2b03e919eeaee621 (patch)
tree86f4aebf8673cee9f17a83017a1c02112f7b57b8
parentafb4f6ae01177010af6008200f09017a660f62a8 (diff)
downloadgo-71dc56dbff5b5c418202788f2b03e919eeaee621.tar.gz
test: add some tests of valid code that failed with gccgo
R=golang-dev, bradfitz CC=golang-dev http://codereview.appspot.com/5971044
-rw-r--r--test/blank.go2
-rw-r--r--test/fixedbugs/bug430.go22
-rw-r--r--test/fixedbugs/bug431.go18
-rw-r--r--test/fixedbugs/bug432.go13
-rw-r--r--test/fixedbugs/bug433.go39
5 files changed, 93 insertions, 1 deletions
diff --git a/test/blank.go b/test/blank.go
index 961ed153b..ee618b148 100644
--- a/test/blank.go
+++ b/test/blank.go
@@ -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
index 000000000..93d5cf2d5
--- /dev/null
+++ b/test/fixedbugs/bug430.go
@@ -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
index 000000000..1057dadcc
--- /dev/null
+++ b/test/fixedbugs/bug431.go
@@ -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
index 000000000..0c1a91461
--- /dev/null
+++ b/test/fixedbugs/bug432.go
@@ -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
index 000000000..1139dfa00
--- /dev/null
+++ b/test/fixedbugs/bug433.go
@@ -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)
+ }
+}