summaryrefslogtreecommitdiff
path: root/gcc/testsuite/go.test
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2018-09-24 21:46:21 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2018-09-24 21:46:21 +0000
commitdd931d9b48647e898dc80927c532ae93cc09e192 (patch)
tree71be2295cd79b8a182f6130611658db8628772d5 /gcc/testsuite/go.test
parent779d8a5ad09b01428726ea5a0e6c87bd9ac3c0e4 (diff)
libgo: update to Go 1.11
Reviewed-on: https://go-review.googlesource.com/136435 gotools/: * Makefile.am (mostlyclean-local): Run chmod on check-go-dir to make sure it is writable. (check-go-tools): Likewise. (check-vet): Copy internal/objabi to check-vet-dir. * Makefile.in: Rebuild. From-SVN: r264546
Diffstat (limited to 'gcc/testsuite/go.test')
-rw-r--r--gcc/testsuite/go.test/test/fixedbugs/bug273.go12
-rw-r--r--gcc/testsuite/go.test/test/fixedbugs/issue4085b.go35
2 files changed, 30 insertions, 17 deletions
diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug273.go b/gcc/testsuite/go.test/test/fixedbugs/bug273.go
index c04f2116c5f..7305c6063cc 100644
--- a/gcc/testsuite/go.test/test/fixedbugs/bug273.go
+++ b/gcc/testsuite/go.test/test/fixedbugs/bug273.go
@@ -8,13 +8,15 @@
package main
+import "unsafe"
+
var bug = false
var minus1 = -1
var five = 5
-var big int64 = 10 | 1<<32
+var big int64 = 10 | 1<<40
-type block [1<<19]byte
+type block [1 << 19]byte
var g1 []block
@@ -48,9 +50,10 @@ func bigcap() {
g1 = make([]block, 10, big)
}
-type cblock [1<<16-1]byte
+type cblock [1<<16 - 1]byte
var g4 chan cblock
+
func badchancap() {
g4 = make(chan cblock, minus1)
}
@@ -60,7 +63,8 @@ func bigchancap() {
}
func overflowchan() {
- g4 = make(chan cblock, 1<<30)
+ const ptrSize = unsafe.Sizeof(uintptr(0))
+ g4 = make(chan cblock, 1<<(30*(ptrSize/4)))
}
func main() {
diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4085b.go b/gcc/testsuite/go.test/test/fixedbugs/issue4085b.go
index 63aca2378ee..6bf315fcc2f 100644
--- a/gcc/testsuite/go.test/test/fixedbugs/issue4085b.go
+++ b/gcc/testsuite/go.test/test/fixedbugs/issue4085b.go
@@ -1,6 +1,6 @@
// run
-// Copyright 2013 The Go Authors. All rights reserved.
+// Copyright 2013 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.
@@ -15,22 +15,31 @@ type T []int
func main() {
n := -1
- shouldPanic("len out of range", func() {_ = make(T, n)})
- shouldPanic("cap out of range", func() {_ = make(T, 0, n)})
+ shouldPanic("len out of range", func() { _ = make(T, n) })
+ shouldPanic("cap out of range", func() { _ = make(T, 0, n) })
+ shouldPanic("len out of range", func() { _ = make(T, int64(n)) })
+ shouldPanic("cap out of range", func() { _ = make(T, 0, int64(n)) })
var t *byte
if unsafe.Sizeof(t) == 8 {
- n = 1<<20
- n <<= 20
- shouldPanic("len out of range", func() {_ = make(T, n)})
- shouldPanic("cap out of range", func() {_ = make(T, 0, n)})
- n <<= 20
- shouldPanic("len out of range", func() {_ = make(T, n)})
- shouldPanic("cap out of range", func() {_ = make(T, 0, n)})
+ var n2 int64 = 1 << 50
+ shouldPanic("len out of range", func() { _ = make(T, int(n2)) })
+ shouldPanic("cap out of range", func() { _ = make(T, 0, int(n2)) })
+ n2 = 1<<63 - 1
+ shouldPanic("len out of range", func() { _ = make(T, int(n2)) })
+ shouldPanic("cap out of range", func() { _ = make(T, 0, int(n2)) })
} else {
n = 1<<31 - 1
- shouldPanic("len out of range", func() {_ = make(T, n)})
- shouldPanic("cap out of range", func() {_ = make(T, 0, n)})
+ shouldPanic("len out of range", func() { _ = make(T, n) })
+ shouldPanic("cap out of range", func() { _ = make(T, 0, n) })
+ shouldPanic("len out of range", func() { _ = make(T, int64(n)) })
+ shouldPanic("cap out of range", func() { _ = make(T, 0, int64(n)) })
}
+
+ // Test make in append panics since the gc compiler optimizes makes in appends.
+ shouldPanic("len out of range", func() { _ = append(T{}, make(T, n)...) })
+ shouldPanic("cap out of range", func() { _ = append(T{}, make(T, 0, n)...) })
+ shouldPanic("len out of range", func() { _ = append(T{}, make(T, int64(n))...) })
+ shouldPanic("cap out of range", func() { _ = append(T{}, make(T, 0, int64(n))...) })
}
func shouldPanic(str string, f func()) {
@@ -44,6 +53,6 @@ func shouldPanic(str string, f func()) {
panic("got panic " + s + ", want " + str)
}
}()
-
+
f()
}