From d39f5aa373a4422f7a5f3ee764fb0f6b0b719d61 Mon Sep 17 00:00:00 2001 From: Ondřej Surý Date: Thu, 30 Jun 2011 15:34:22 +0200 Subject: Imported Upstream version 58 --- test/bench/timing.log | 8 +++++++ test/bugs/bug322.dir/lib.go | 15 ------------- test/bugs/bug322.dir/main.go | 47 --------------------------------------- test/bugs/bug322.go | 8 ------- test/ddd1.go | 1 + test/fixedbugs/bug226.dir/y.go | 2 +- test/fixedbugs/bug322.dir/lib.go | 15 +++++++++++++ test/fixedbugs/bug322.dir/main.go | 40 +++++++++++++++++++++++++++++++++ test/fixedbugs/bug322.go | 8 +++++++ test/fixedbugs/bug337.go | 19 ++++++++++++++++ test/fixedbugs/bug338.go | 22 ++++++++++++++++++ test/fixedbugs/bug339.go | 20 +++++++++++++++++ test/fixedbugs/bug340.go | 17 ++++++++++++++ test/fixedbugs/bug341.go | 22 ++++++++++++++++++ test/fixedbugs/bug342.go | 24 ++++++++++++++++++++ test/fixedbugs/bug343.go | 33 +++++++++++++++++++++++++++ test/golden.out | 5 ----- test/shift1.go | 36 ++++++++++++++++++++++++++++++ test/shift2.go | 42 ++++++++++++++++++++++++++++++++++ 19 files changed, 308 insertions(+), 76 deletions(-) delete mode 100644 test/bugs/bug322.dir/lib.go delete mode 100644 test/bugs/bug322.dir/main.go delete mode 100644 test/bugs/bug322.go create mode 100644 test/fixedbugs/bug322.dir/lib.go create mode 100644 test/fixedbugs/bug322.dir/main.go create mode 100644 test/fixedbugs/bug322.go create mode 100644 test/fixedbugs/bug337.go create mode 100644 test/fixedbugs/bug338.go create mode 100644 test/fixedbugs/bug339.go create mode 100644 test/fixedbugs/bug340.go create mode 100644 test/fixedbugs/bug341.go create mode 100644 test/fixedbugs/bug342.go create mode 100644 test/fixedbugs/bug343.go create mode 100644 test/shift1.go create mode 100644 test/shift2.go (limited to 'test') diff --git a/test/bench/timing.log b/test/bench/timing.log index c658fa098..e66797982 100644 --- a/test/bench/timing.log +++ b/test/bench/timing.log @@ -844,3 +844,11 @@ NEW: gcc -O2 chameneosredux.c -lpthread 8.05u 63.43s 11.16r gccgo -O2 chameneosredux.go 82.95u 304.37s 207.64r gc chameneosredux 9.42u 0.00s 9.43r + +# May 13, 2011 +# after gc update to inline append when possible - 35% faster + +regex-dna 100000 + gc regex-dna 3.94u 0.00s 3.95r + gc regex-dna-parallel 4.15u 0.01s 1.63r + gc_B regex-dna 4.01u 0.01s 4.02r diff --git a/test/bugs/bug322.dir/lib.go b/test/bugs/bug322.dir/lib.go deleted file mode 100644 index 0de56d3d6..000000000 --- a/test/bugs/bug322.dir/lib.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2011 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. - -package lib - -type T struct { - x int // non-exported field -} - -func (t T) M() { -} - -func (t *T) PM() { -} diff --git a/test/bugs/bug322.dir/main.go b/test/bugs/bug322.dir/main.go deleted file mode 100644 index 0ab5b32e4..000000000 --- a/test/bugs/bug322.dir/main.go +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2011 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. - -package main - -import "./lib" - -type I interface { - M() -} - -type PI interface { - PM() -} - -func main() { - var t lib.T - t.M() - t.PM() - - // This is still an error. - // var i1 I = t - // i1.M() - - // This combination is illegal because - // PM requires a pointer receiver. - // var pi1 PI = t - // pi1.PM() - - var pt = &t - pt.M() - pt.PM() - - var i2 I = pt - i2.M() - - var pi2 PI = pt - pi2.PM() -} - -/* -These should not be errors anymore: - -bug322.dir/main.go:19: implicit assignment of unexported field 'x' of lib.T in method receiver -bug322.dir/main.go:32: implicit assignment of unexported field 'x' of lib.T in method receiver -*/ diff --git a/test/bugs/bug322.go b/test/bugs/bug322.go deleted file mode 100644 index ad0e62dc8..000000000 --- a/test/bugs/bug322.go +++ /dev/null @@ -1,8 +0,0 @@ -// $G $D/$F.dir/lib.go && $G $D/$F.dir/main.go && $L main.$A && ./$A.out || echo BUG: fails incorrectly - -// Copyright 2011 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 case for issue 1402. -ignored diff --git a/test/ddd1.go b/test/ddd1.go index a0bc73814..96a358e1c 100644 --- a/test/ddd1.go +++ b/test/ddd1.go @@ -43,4 +43,5 @@ func bad(args ...int) { var x int _ = unsafe.Pointer(&x...) // ERROR "[.][.][.]" _ = unsafe.Sizeof(x...) // ERROR "[.][.][.]" + _ = [...]byte("foo") // ERROR "[.][.][.]" } diff --git a/test/fixedbugs/bug226.dir/y.go b/test/fixedbugs/bug226.dir/y.go index 01e8b7b43..c66d592b7 100644 --- a/test/fixedbugs/bug226.dir/y.go +++ b/test/fixedbugs/bug226.dir/y.go @@ -15,7 +15,7 @@ func f() { _ = x.T{}; _ = x.T{Y:2}; - ok1.M(); // ERROR "assignment.*T" + ok1.M(); bad1 := *ok; // ERROR "assignment.*T" bad2 := ok1; // ERROR "assignment.*T" *ok4 = ok1; // ERROR "assignment.*T" diff --git a/test/fixedbugs/bug322.dir/lib.go b/test/fixedbugs/bug322.dir/lib.go new file mode 100644 index 000000000..0de56d3d6 --- /dev/null +++ b/test/fixedbugs/bug322.dir/lib.go @@ -0,0 +1,15 @@ +// Copyright 2011 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. + +package lib + +type T struct { + x int // non-exported field +} + +func (t T) M() { +} + +func (t *T) PM() { +} diff --git a/test/fixedbugs/bug322.dir/main.go b/test/fixedbugs/bug322.dir/main.go new file mode 100644 index 000000000..f403c7d32 --- /dev/null +++ b/test/fixedbugs/bug322.dir/main.go @@ -0,0 +1,40 @@ +// Copyright 2011 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. + +package main + +import "./lib" + +type I interface { + M() +} + +type PI interface { + PM() +} + +func main() { + var t lib.T + t.M() + t.PM() + + // This is still an error. + // var i1 I = t + // i1.M() + + // This combination is illegal because + // PM requires a pointer receiver. + // var pi1 PI = t + // pi1.PM() + + var pt = &t + pt.M() + pt.PM() + + var i2 I = pt + i2.M() + + var pi2 PI = pt + pi2.PM() +} diff --git a/test/fixedbugs/bug322.go b/test/fixedbugs/bug322.go new file mode 100644 index 000000000..ad0e62dc8 --- /dev/null +++ b/test/fixedbugs/bug322.go @@ -0,0 +1,8 @@ +// $G $D/$F.dir/lib.go && $G $D/$F.dir/main.go && $L main.$A && ./$A.out || echo BUG: fails incorrectly + +// Copyright 2011 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 case for issue 1402. +ignored diff --git a/test/fixedbugs/bug337.go b/test/fixedbugs/bug337.go new file mode 100644 index 000000000..62e310e72 --- /dev/null +++ b/test/fixedbugs/bug337.go @@ -0,0 +1,19 @@ +// errchk $G $D/$F.go + +// Copyright 2011 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. + +// Issue 1722. + +// Check that the error messages says +// bug337.go:16: len("foo") not used +// and not +// bug337.go:16: 3 not used + +package main + +func main() { + len("foo") // ERROR "len" +} + diff --git a/test/fixedbugs/bug338.go b/test/fixedbugs/bug338.go new file mode 100644 index 000000000..c368a7fad --- /dev/null +++ b/test/fixedbugs/bug338.go @@ -0,0 +1,22 @@ +// $G $D/$F.go + +// Copyright 2011 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. + +// Issue 1787. + +package main + +import "unsafe" + +const x = unsafe.Sizeof([8]byte{}) + +func main() { + var b [x]int + _ = b +} + +/* +bug338.go:14: array bound must be non-negative +*/ diff --git a/test/fixedbugs/bug339.go b/test/fixedbugs/bug339.go new file mode 100644 index 000000000..eac7c5ee6 --- /dev/null +++ b/test/fixedbugs/bug339.go @@ -0,0 +1,20 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2011 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. + +// Issue 1608. +// Size used to be -1000000000. + +package main + +import "unsafe" + +func main() { + var a interface{} = 0 + size := unsafe.Sizeof(a) + if size != 2*unsafe.Sizeof((*int)(nil)) { + println("wrong size: ", size) + } +} diff --git a/test/fixedbugs/bug340.go b/test/fixedbugs/bug340.go new file mode 100644 index 000000000..461cc6cd4 --- /dev/null +++ b/test/fixedbugs/bug340.go @@ -0,0 +1,17 @@ +// errchk $G $D/$F.go + +// Copyright 2011 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. + +// Issue 1606. + +package main + +func main() { + var x interface{} + switch t := x.(type) { // ERROR "0 is not a type" + case 0: + t.x = 1 // ERROR "type interface \{ \}" + } +} diff --git a/test/fixedbugs/bug341.go b/test/fixedbugs/bug341.go new file mode 100644 index 000000000..8ee52e1ef --- /dev/null +++ b/test/fixedbugs/bug341.go @@ -0,0 +1,22 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug341 + +// Copyright 2011 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. + +// Used to panic because 8g was generating incorrect +// code for converting a negative float to a uint64. + +package main + +func main() { + var x float32 = -2.5 + + _ = uint64(x) + _ = float32(0) +} +/* +panic: runtime error: floating point error + +[signal 0x8 code=0x6 addr=0x8048c64 pc=0x8048c64] +*/ diff --git a/test/fixedbugs/bug342.go b/test/fixedbugs/bug342.go new file mode 100644 index 000000000..0852cdd34 --- /dev/null +++ b/test/fixedbugs/bug342.go @@ -0,0 +1,24 @@ +// errchk $G $D/$F.go + +// Copyright 2011 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. + +// Issue 1871. + +package p + +type a interface { + foo(x int) (x int) // ERROR "redeclared|redefinition" +} + +var b interface { + bar(y int) (y int) // ERROR "redeclared|redefinition" +} + +/* +Previously: + +bug.go:1 x redclared in this block + previous declaration at bug.go:1 +*/ diff --git a/test/fixedbugs/bug343.go b/test/fixedbugs/bug343.go new file mode 100644 index 000000000..efc87e3d7 --- /dev/null +++ b/test/fixedbugs/bug343.go @@ -0,0 +1,33 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug343 + +// Copyright 2011 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. + +// issue 1900 + +package main + +func getArgs(data map[string]interface{}, keys ...string) map[string]string { + ret := map[string]string{} + var ok bool + for _, k := range keys { + ret[k], ok = data[k].(string) + if !ok {} + } + return ret +} + +func main() { + x := getArgs(map[string]interface{}{"x":"y"}, "x") + if x["x"] != "y" { + println("BUG bug343", x) + } +} + + +/* +typecheck [1008592b0] +. INDREG a(1) l(15) x(24) tc(2) runtime.ret G0 string +bug343.go:15: internal compiler error: typecheck INDREG +*/ diff --git a/test/golden.out b/test/golden.out index 725e8de44..4400e41dd 100644 --- a/test/golden.out +++ b/test/golden.out @@ -161,8 +161,3 @@ panic: interface conversion: interface is main.T, not main.T 0x0 == bugs/ - -=========== bugs/bug322.go -bugs/bug322.dir/main.go:19: implicit assignment of unexported field 'x' of lib.T in method receiver -bugs/bug322.dir/main.go:32: implicit assignment of unexported field 'x' of lib.T in method receiver -BUG: fails incorrectly diff --git a/test/shift1.go b/test/shift1.go new file mode 100644 index 000000000..8fa48a03c --- /dev/null +++ b/test/shift1.go @@ -0,0 +1,36 @@ +// errchk $G -e $D/$F.go + +// Copyright 2011 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. + +// Issue 1708, illegal cases. + +package p + +func f(x int) int { return 0 } +func g(x interface{}) int { return 0 } +func h(x float64) int { return 0 } + +// from the spec +var ( + s uint = 33 + u = 1.0 << s // ERROR "invalid operation" + v float32 = 1 << s // ERROR "invalid operation" +) + +// non-constant shift expressions +var ( + e1 = g(2.0 << s) // ERROR "invalid operation" + f1 = h(2 << s) // ERROR "invalid operation" + g1 int64 = 1.1 << s // ERROR "truncated" +) + +// constant shift expressions +const c uint = 65 + +var ( + a2 int = 1.0 << c // ERROR "overflow" + b2 = 1.0 << c // ERROR "overflow" + d2 = f(1.0 << c) // ERROR "overflow" +) diff --git a/test/shift2.go b/test/shift2.go new file mode 100644 index 000000000..ec4c7addc --- /dev/null +++ b/test/shift2.go @@ -0,0 +1,42 @@ +// $G $D/$F.go || echo BUG: shift2 + +// Copyright 2011 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. + +// Issue 1708, legal cases. + +package p + +func f(x int) int { return 0 } +func g(x interface{}) int { return 0 } +func h(x float64) int { return 0 } + +// from the spec +var ( + s uint = 33 + i = 1 << s // 1 has type int + j int32 = 1 << s // 1 has type int32; j == 0 + k = uint64(1 << s) // 1 has type uint64; k == 1<<33 + m int = 1.0 << s // legal: 1.0 has type int + w int64 = 1.0 << 33 // legal: 1.0<<33 is a constant shift expression +) + +// non-constant shift expressions +var ( + a1 int = 2.0 << s // typeof(2.0) is int in this context => legal shift + d1 = f(2.0 << s) // typeof(2.0) is int in this context => legal shift +) + +// constant shift expressions +const c uint = 5 + +var ( + a2 int = 2.0 << c // a2 == 64 (type int) + b2 = 2.0 << c // b2 == 64 (untyped integer) + _ = f(b2) // verify b2 has type int + c2 float64 = 2 << c // c2 == 64.0 (type float64) + d2 = f(2.0 << c) // == f(64) + e2 = g(2.0 << c) // == g(int(64)) + f2 = h(2 << c) // == h(float64(64.0)) +) -- cgit v1.2.3