diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/go/gofrontend/MERGE | 2 | ||||
-rw-r--r-- | gcc/testsuite/go.test/test/fixedbugs/bug273.go | 12 | ||||
-rw-r--r-- | gcc/testsuite/go.test/test/fixedbugs/issue4085b.go | 35 |
3 files changed, 31 insertions, 18 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 3af5bd4..175db5d 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -92a14213215fd93df7240fa9d376a1213b1d5a74 +7b25b4dff4778fc4d6b5d6e10594814146b3e5dd The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug273.go b/gcc/testsuite/go.test/test/fixedbugs/bug273.go index c04f211..7305c60 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 63aca23..6bf315f 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() } |