diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/alias2.go | 10 | ||||
-rw-r--r-- | test/codegen/arithmetic.go | 4 | ||||
-rw-r--r-- | test/codegen/bits.go | 5 | ||||
-rw-r--r-- | test/codegen/mathbits.go | 1 | ||||
-rw-r--r-- | test/codegen/shift.go | 46 | ||||
-rw-r--r-- | test/fixedbugs/issue11361.go | 2 | ||||
-rw-r--r-- | test/fixedbugs/issue20789.go | 2 | ||||
-rw-r--r-- | test/fixedbugs/issue21317.go | 4 | ||||
-rw-r--r-- | test/fixedbugs/issue23664.go | 6 | ||||
-rw-r--r-- | test/fixedbugs/issue28268.go | 4 | ||||
-rw-r--r-- | test/fixedbugs/issue29870b.go | 2 | ||||
-rw-r--r-- | test/fixedbugs/issue34329.go | 4 | ||||
-rw-r--r-- | test/fixedbugs/issue65893.go | 16 | ||||
-rw-r--r-- | test/fixedbugs/issue66873.go | 15 | ||||
-rw-r--r-- | test/fixedbugs/issue67141.go | 15 | ||||
-rw-r--r-- | test/fixedbugs/issue67160.go | 32 | ||||
-rw-r--r-- | test/fixedbugs/issue67255.go | 33 | ||||
-rw-r--r-- | test/linkname3.go | 6 | ||||
-rw-r--r-- | test/linknameasm.dir/a_amd64.s | 7 | ||||
-rw-r--r-- | test/linknameasm.dir/x.go | 26 | ||||
-rw-r--r-- | test/linknameasm.go | 9 |
21 files changed, 228 insertions, 21 deletions
diff --git a/test/alias2.go b/test/alias2.go index 2846e5dc31..95eb25a94b 100644 --- a/test/alias2.go +++ b/test/alias2.go @@ -47,7 +47,7 @@ var _ T0 = A0{} // But aliases and original types cannot be used with new types based on them. var _ N0 = T0{} // ERROR "cannot use T0{} \(value of type T0\) as N0 value in variable declaration" -var _ N0 = A0{} // ERROR "cannot use A0{} \(value of type T0\) as N0 value in variable declaration" +var _ N0 = A0{} // ERROR "cannot use A0{} \(value of type A0\) as N0 value in variable declaration" var _ A5 = Value{} @@ -83,7 +83,7 @@ func _() { var _ T0 = A0{} var _ N0 = T0{} // ERROR "cannot use T0{} \(value of type T0\) as N0 value in variable declaration" - var _ N0 = A0{} // ERROR "cannot use A0{} \(value of type T0\) as N0 value in variable declaration" + var _ N0 = A0{} // ERROR "cannot use A0{} \(value of type A0\) as N0 value in variable declaration" var _ A5 = Value{} // ERROR "cannot use Value{} \(value of type reflect\.Value\) as A5 value in variable declaration" } @@ -92,10 +92,10 @@ func _() { type _ = reflect.ValueOf // ERROR "reflect.ValueOf .*is not a type|expected type" -func (A1) m() {} // ERROR "cannot define new methods on non-local type int|may not define methods on non-local type" +func (A1) m() {} // ERROR "cannot define new methods on non-local type|may not define methods on non-local type" func (A2) m() {} // ERROR "invalid receiver type" -func (A3) m() {} // ERROR "cannot define new methods on non-local type reflect.Value|may not define methods on non-local type" -func (A4) m() {} // ERROR "cannot define new methods on non-local type reflect.Value|may not define methods on non-local type" +func (A3) m() {} // ERROR "cannot define new methods on non-local type|may not define methods on non-local type" +func (A4) m() {} // ERROR "cannot define new methods on non-local type|may not define methods on non-local type" type B1 = struct{} diff --git a/test/codegen/arithmetic.go b/test/codegen/arithmetic.go index dc3bab7be9..e474a10ba2 100644 --- a/test/codegen/arithmetic.go +++ b/test/codegen/arithmetic.go @@ -320,14 +320,14 @@ func Pow2DivisibleSigned(n1, n2 int) (bool, bool) { // amd64:"TESTQ\t[$]63",-"DIVQ",-"SHRQ" // arm:"AND\t[$]63",-".*udiv",-"SRA" // arm64:"TST\t[$]63",-"UDIV",-"ASR",-"AND" - // ppc64x:"RLDICL",-"SRAD" + // ppc64x:"ANDCC",-"RLDICL",-"SRAD",-"CMP" a := n1%64 == 0 // signed divisible // 386:"TESTL\t[$]63",-"DIVL",-"SHRL" // amd64:"TESTQ\t[$]63",-"DIVQ",-"SHRQ" // arm:"AND\t[$]63",-".*udiv",-"SRA" // arm64:"TST\t[$]63",-"UDIV",-"ASR",-"AND" - // ppc64x:"RLDICL",-"SRAD" + // ppc64x:"ANDCC",-"RLDICL",-"SRAD",-"CMP" b := n2%64 != 0 // signed indivisible return a, b diff --git a/test/codegen/bits.go b/test/codegen/bits.go index 4b6c8b94b8..554e363ef5 100644 --- a/test/codegen/bits.go +++ b/test/codegen/bits.go @@ -394,7 +394,7 @@ func zeroextendAndMask8to64(a int8, b int16) (x, y uint64) { } // Verify rotate and mask instructions, and further simplified instructions for small types -func bitRotateAndMask(io64 [4]uint64, io32 [4]uint32, io16 [4]uint16, io8 [4]uint8) { +func bitRotateAndMask(io64 [8]uint64, io32 [4]uint32, io16 [4]uint16, io8 [4]uint8) { // ppc64x: "RLDICR\t[$]0, R[0-9]*, [$]47, R" io64[0] = io64[0] & 0xFFFFFFFFFFFF0000 // ppc64x: "RLDICL\t[$]0, R[0-9]*, [$]16, R" @@ -404,6 +404,9 @@ func bitRotateAndMask(io64 [4]uint64, io32 [4]uint32, io16 [4]uint16, io8 [4]uin // ppc64x: -"SRD", -"AND", "RLDICL\t[$]36, R[0-9]*, [$]28, R" io64[3] = (io64[3] >> 28) & 0x0000FFFFFFFFFFFF + // ppc64x: "MOVWZ", "RLWNM\t[$]1, R[0-9]*, [$]28, [$]3, R" + io64[4] = uint64(bits.RotateLeft32(io32[0], 1) & 0xF000000F) + // ppc64x: "RLWNM\t[$]0, R[0-9]*, [$]4, [$]19, R" io32[0] = io32[0] & 0x0FFFF000 // ppc64x: "RLWNM\t[$]0, R[0-9]*, [$]20, [$]3, R" diff --git a/test/codegen/mathbits.go b/test/codegen/mathbits.go index 82a139acab..a743eaf3d3 100644 --- a/test/codegen/mathbits.go +++ b/test/codegen/mathbits.go @@ -827,6 +827,7 @@ func Mul(x, y uint) (hi, lo uint) { // ppc64x:"MULHDU","MULLD" // s390x:"MLGR" // mips64: "MULVU" + // riscv64:"MULHU","MUL" return bits.Mul(x, y) } diff --git a/test/codegen/shift.go b/test/codegen/shift.go index 50d60426d0..6a2a6c40cd 100644 --- a/test/codegen/shift.go +++ b/test/codegen/shift.go @@ -453,6 +453,52 @@ func checkMergedShifts32(a [256]uint32, b [256]uint64, u uint32, v uint32) { b[2] = b[v>>25] } +func checkMergedShifts64(a [256]uint32, b [256]uint64, c [256]byte, v uint64) { + // ppc64x: -"CLRLSLDI", "RLWNM\t[$]10, R[0-9]+, [$]22, [$]29, R[0-9]+" + a[0] = a[uint8(v>>24)] + // ppc64x: "SRD", "CLRLSLDI", -"RLWNM" + a[1] = a[uint8(v>>25)] + // ppc64x: -"CLRLSLDI", "RLWNM\t[$]9, R[0-9]+, [$]23, [$]29, R[0-9]+" + a[2] = a[v>>25&0x7F] + // ppc64x: -"CLRLSLDI", "RLWNM\t[$]3, R[0-9]+, [$]29, [$]29, R[0-9]+" + a[3] = a[(v>>31)&0x01] + // ppc64x: "SRD", "CLRLSLDI", -"RLWNM" + a[4] = a[(v>>30)&0x07] + // ppc64x: "SRD", "CLRLSLDI", -"RLWNM" + a[5] = a[(v>>32)&0x01] + // ppc64x: "SRD", "CLRLSLDI", -"RLWNM" + a[6] = a[(v>>34)&0x03] + // ppc64x: -"CLRLSLDI", "RLWNM\t[$]12, R[0-9]+, [$]21, [$]28, R[0-9]+" + b[0] = b[uint8(v>>23)] + // ppc64x: -"CLRLSLDI", "RLWNM\t[$]15, R[0-9]+, [$]21, [$]28, R[0-9]+" + b[1] = b[(v>>20)&0xFF] + // ppc64x: "RLWNM", -"SLD" + b[2] = b[((uint64((uint32(v) >> 21)) & 0x3f) << 4)] + // ppc64x: "RLWNM\t[$]11, R[0-9]+, [$]10, [$]15" + c[0] = c[((v>>5)&0x3F)<<16] + // ppc64x: "RLWNM\t[$]0, R[0-9]+, [$]19, [$]24" + c[1] = c[((v>>7)&0x3F)<<7] +} + +func checkShiftMask(a uint32, b uint64, z []uint32, y []uint64) { + _ = y[128] + _ = z[128] + // ppc64x: -"MOVBZ", -"SRW", "RLWNM" + z[0] = uint32(uint8(a >> 5)) + // ppc64x: -"MOVBZ", -"SRW", "RLWNM" + z[1] = uint32(uint8((a >> 4) & 0x7e)) + // ppc64x: "RLWNM\t[$]25, R[0-9]+, [$]27, [$]29, R[0-9]+" + z[2] = uint32(uint8(a>>7)) & 0x1c + // ppc64x: -"MOVWZ" + y[0] = uint64((a >> 6) & 0x1c) + // ppc64x: -"MOVWZ" + y[1] = uint64(uint32(b)<<6) + 1 + // ppc64x: -"MOVHZ", -"MOVWZ" + y[2] = uint64((uint16(a) >> 9) & 0x1F) + // ppc64x: -"MOVHZ", -"MOVWZ", -"ANDCC" + y[3] = uint64(((uint16(a) & 0xFF0) >> 9) & 0x1F) +} + // 128 bit shifts func check128bitShifts(x, y uint64, bits uint) (uint64, uint64) { diff --git a/test/fixedbugs/issue11361.go b/test/fixedbugs/issue11361.go index 84e71c73e6..1ef8735a52 100644 --- a/test/fixedbugs/issue11361.go +++ b/test/fixedbugs/issue11361.go @@ -8,4 +8,4 @@ package a import "fmt" // GC_ERROR "imported and not used" -const n = fmt // ERROR "fmt without selector|unexpected reference to package|use of package `fmt' not in selector" +const n = fmt // ERROR "fmt without selector|unexpected reference to package|use of package fmt not in selector" diff --git a/test/fixedbugs/issue20789.go b/test/fixedbugs/issue20789.go index cba1290957..6a0b7961f3 100644 --- a/test/fixedbugs/issue20789.go +++ b/test/fixedbugs/issue20789.go @@ -10,4 +10,4 @@ // there yet, so put it here for now. See also #20800.) package e -func([<-chan<-[func u){go // ERROR "unexpected `u'"
\ No newline at end of file +func([<-chan<-[func u){go // ERROR "unexpected name u"
\ No newline at end of file diff --git a/test/fixedbugs/issue21317.go b/test/fixedbugs/issue21317.go index d525f12a58..8162548151 100644 --- a/test/fixedbugs/issue21317.go +++ b/test/fixedbugs/issue21317.go @@ -45,8 +45,8 @@ func main() { log.Fatalf("expected cmd/compile to fail") } wantErrs := []string{ - "7:9: `n' declared and not used", - "7:12: `err' declared and not used", + "7:9: declared and not used: n", + "7:12: declared and not used: err", } outStr := string(out) for _, want := range wantErrs { diff --git a/test/fixedbugs/issue23664.go b/test/fixedbugs/issue23664.go index fe171c27d0..3b54f3cf1e 100644 --- a/test/fixedbugs/issue23664.go +++ b/test/fixedbugs/issue23664.go @@ -9,9 +9,9 @@ package p func f() { - if f() true { // ERROR "unexpected `true', expected {" + if f() true { // ERROR "unexpected name true, expected {" } - - switch f() true { // ERROR "unexpected `true', expected {" + + switch f() true { // ERROR "unexpected name true, expected {" } } diff --git a/test/fixedbugs/issue28268.go b/test/fixedbugs/issue28268.go index b04e42555f..263b2d1b42 100644 --- a/test/fixedbugs/issue28268.go +++ b/test/fixedbugs/issue28268.go @@ -16,8 +16,8 @@ type T struct { type E struct{} -func (T) b() {} // ERROR "field and method named b|redeclares struct field name|field and method with the same name `b'" -func (*T) E() {} // ERROR "field and method named E|redeclares struct field name|field and method with the same name `E'" +func (T) b() {} // ERROR "field and method named b|redeclares struct field name|field and method with the same name b" +func (*T) E() {} // ERROR "field and method named E|redeclares struct field name|field and method with the same name E" func _() { var x T diff --git a/test/fixedbugs/issue29870b.go b/test/fixedbugs/issue29870b.go index c7cdd8c8c7..df50b0522d 100644 --- a/test/fixedbugs/issue29870b.go +++ b/test/fixedbugs/issue29870b.go @@ -10,5 +10,5 @@ package main func _() { - x := 7 // ERROR ".*x.* declared and not used" + x := 7 // ERROR "declared and not used" } diff --git a/test/fixedbugs/issue34329.go b/test/fixedbugs/issue34329.go index 585770d87a..21f952cefd 100644 --- a/test/fixedbugs/issue34329.go +++ b/test/fixedbugs/issue34329.go @@ -6,9 +6,9 @@ package p -type I interface { M() } +type I interface{ M() } type _ interface { I - I // ERROR "duplicate method `M'" + I // ERROR "duplicate method M" } diff --git a/test/fixedbugs/issue65893.go b/test/fixedbugs/issue65893.go new file mode 100644 index 0000000000..6f015feaed --- /dev/null +++ b/test/fixedbugs/issue65893.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2024 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 p + +type ( + s = struct{ f func(s1) } + s1 = struct{ i I } +) + +type I interface { + S() *s +} diff --git a/test/fixedbugs/issue66873.go b/test/fixedbugs/issue66873.go new file mode 100644 index 0000000000..2f49cc933d --- /dev/null +++ b/test/fixedbugs/issue66873.go @@ -0,0 +1,15 @@ +// compile + +// Copyright 2024 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 p + +func f(A) {} + +type T int + +type A = T + +func (A) m() {} diff --git a/test/fixedbugs/issue67141.go b/test/fixedbugs/issue67141.go new file mode 100644 index 0000000000..0464d1f9e5 --- /dev/null +++ b/test/fixedbugs/issue67141.go @@ -0,0 +1,15 @@ +// errorcheck -lang=go1.22 + +//go:build go1.21 + +// We need a line directive before the package clause, +// but don't change file name or position so that the +// error message appears at the right place. + +//line issue67141.go:10 +package p + +func _() { + for range 10 { // ERROR "cannot range over 10" + } +} diff --git a/test/fixedbugs/issue67160.go b/test/fixedbugs/issue67160.go new file mode 100644 index 0000000000..be45a61420 --- /dev/null +++ b/test/fixedbugs/issue67160.go @@ -0,0 +1,32 @@ +// run + +// Copyright 2024 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 to make sure that we don't try using larger loads for +// generated equality functions on architectures that can't do +// unaligned loads. + +package main + +// T has a big field that wants to be compared with larger loads/stores. +// T is "special" because of the unnamed field, so it needs a generated equality function. +// T is an odd number of bytes in size and has alignment 1. +type T struct { + src [8]byte + _ byte +} + +// U contains 8 copies of T, each at a different %8 alignment. +type U [8]T + +//go:noinline +func f(x, y *U) bool { + return *x == *y +} + +func main() { + var a U + _ = f(&a, &a) +} diff --git a/test/fixedbugs/issue67255.go b/test/fixedbugs/issue67255.go new file mode 100644 index 0000000000..7ca7a239dd --- /dev/null +++ b/test/fixedbugs/issue67255.go @@ -0,0 +1,33 @@ +// run + +// Copyright 2024 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 + +var zero int + +var sink any + +func main() { + var objs [][]*byte + for i := 10; i < 200; i++ { + // The objects we're allocating here are pointer-ful. Some will + // max out their size class, which are the ones we want. + // We also allocate from small to large, so that the object which + // maxes out its size class is the last one allocated in that class. + // This allocation pattern leaves the next object in the class + // unallocated, which we need to reproduce the bug. + objs = append(objs, make([]*byte, i)) + } + sink = objs // force heap allocation + + // Bug will happen as soon as the write barrier turns on. + for range 10000 { + sink = make([]*byte, 1024) + for _, s := range objs { + s = append(s, make([]*byte, zero)...) + } + } +} diff --git a/test/linkname3.go b/test/linkname3.go index df110cd064..0d5df0b86e 100644 --- a/test/linkname3.go +++ b/test/linkname3.go @@ -13,13 +13,17 @@ type t int var x, y int +func F[T any](T) {} + //go:linkname x ok // ERROR "//go:linkname must refer to declared function or variable" // ERROR "//go:linkname must refer to declared function or variable" // ERROR "duplicate //go:linkname for x" +// ERROR "//go:linkname reference of an instantiation is not allowed" -//line linkname3.go:18 +//line linkname3.go:20 //go:linkname nonexist nonexist //go:linkname t notvarfunc //go:linkname x duplicate +//go:linkname i F[go.shape.int] diff --git a/test/linknameasm.dir/a_amd64.s b/test/linknameasm.dir/a_amd64.s new file mode 100644 index 0000000000..2799609cd7 --- /dev/null +++ b/test/linknameasm.dir/a_amd64.s @@ -0,0 +1,7 @@ +// Copyright 2024 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. + +TEXT ·asm(SB),0,$0-8 + CALL ·callback(SB) + RET diff --git a/test/linknameasm.dir/x.go b/test/linknameasm.dir/x.go new file mode 100644 index 0000000000..38bca6f7d7 --- /dev/null +++ b/test/linknameasm.dir/x.go @@ -0,0 +1,26 @@ +// Copyright 2024 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 a linkname applied on an assembly declaration +// does not affect stack map generation. + +package main + +import ( + "runtime" + _ "unsafe" +) + +//go:linkname asm +func asm(*int) + +func main() { + x := new(int) + asm(x) +} + +// called from asm +func callback() { + runtime.GC() // scan stack +} diff --git a/test/linknameasm.go b/test/linknameasm.go new file mode 100644 index 0000000000..119f4bda42 --- /dev/null +++ b/test/linknameasm.go @@ -0,0 +1,9 @@ +// buildrundir + +// Copyright 2024 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. + +//go:build amd64 + +package ignored |