From 71dc56dbff5b5c418202788f2b03e919eeaee621 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 30 Mar 2012 08:42:21 -0700 Subject: test: add some tests of valid code that failed with gccgo R=golang-dev, bradfitz CC=golang-dev http://codereview.appspot.com/5971044 --- test/blank.go | 2 +- test/fixedbugs/bug430.go | 22 ++++++++++++++++++++++ test/fixedbugs/bug431.go | 18 ++++++++++++++++++ test/fixedbugs/bug432.go | 13 +++++++++++++ test/fixedbugs/bug433.go | 39 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 test/fixedbugs/bug430.go create mode 100644 test/fixedbugs/bug431.go create mode 100644 test/fixedbugs/bug432.go create mode 100644 test/fixedbugs/bug433.go 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) + } +} -- cgit v1.2.1