summaryrefslogtreecommitdiff
path: root/test/prove.go
diff options
context:
space:
mode:
authorDavid Chase <drchase@google.com>2018-12-04 10:00:16 -0500
committerDavid Chase <drchase@google.com>2018-12-07 23:04:58 +0000
commitea6259d5e9d57f247b7d877d4d04602b74ae5155 (patch)
treec4449109691f8e28591b43ac6b023c933e32b540 /test/prove.go
parent179909f20556262422a8b99c059eacdfcebc48ee (diff)
downloadgo-git-ea6259d5e9d57f247b7d877d4d04602b74ae5155.tar.gz
cmd/compile: check for negative upper bound to IsSliceInBounds
IsSliceInBounds(x, y) asserts that y is not negative, but there were cases where this is not true. Change code generation to ensure that this is true when it's not obviously true. Prove phase cleans a few of these out. With this change the compiler text section is 0.06% larger, that is, not very much. Benchmarking still TBD, may need to wait for access to a benchmarking box (next week). Also corrected run.go to handle '?' in -update_errors output. Fixes #28797. Change-Id: Ia8af90bc50a91ae6e934ef973def8d3f398fac7b Reviewed-on: https://go-review.googlesource.com/c/152477 Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'test/prove.go')
-rw-r--r--test/prove.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/test/prove.go b/test/prove.go
index 79256893b3..0de6bd63b4 100644
--- a/test/prove.go
+++ b/test/prove.go
@@ -62,7 +62,7 @@ func f1c(a []int, i int64) int {
}
func f2(a []int) int {
- for i := range a { // ERROR "Induction variable: limits \[0,\?\), increment 1"
+ for i := range a { // ERROR "Induction variable: limits \[0,\?\), increment 1$"
a[i+1] = i
a[i+1] = i // ERROR "Proved IsInBounds$"
}
@@ -269,7 +269,7 @@ func f11b(a []int, i int) {
func f11c(a []int, i int) {
useSlice(a[:i])
- useSlice(a[:i]) // ERROR "Proved IsSliceInBounds$"
+ useSlice(a[:i]) // ERROR "Proved Geq64$" "Proved IsSliceInBounds$"
}
func f11d(a []int, i int) {
@@ -464,12 +464,12 @@ func f16(s []int) []int {
}
func f17(b []int) {
- for i := 0; i < len(b); i++ { // ERROR "Induction variable: limits \[0,\?\), increment 1"
+ for i := 0; i < len(b); i++ { // ERROR "Induction variable: limits \[0,\?\), increment 1$"
// This tests for i <= cap, which we can only prove
// using the derived relation between len and cap.
// This depends on finding the contradiction, since we
// don't query this condition directly.
- useSlice(b[:i]) // ERROR "Proved IsSliceInBounds$"
+ useSlice(b[:i]) // ERROR "Proved Geq64$" "Proved IsSliceInBounds$"
}
}
@@ -579,18 +579,18 @@ func fence4(x, y int64) {
func trans1(x, y int64) {
if x > 5 {
if y > x {
- if y > 2 { // ERROR "Proved Greater64"
+ if y > 2 { // ERROR "Proved Greater64$"
return
}
} else if y == x {
- if y > 5 { // ERROR "Proved Greater64"
+ if y > 5 { // ERROR "Proved Greater64$"
return
}
}
}
if x >= 10 {
if y > x {
- if y > 10 { // ERROR "Proved Greater64"
+ if y > 10 { // ERROR "Proved Greater64$"
return
}
}
@@ -624,7 +624,7 @@ func natcmp(x, y []uint) (r int) {
}
i := m - 1
- for i > 0 && // ERROR "Induction variable: limits \(0,\?\], increment 1"
+ for i > 0 && // ERROR "Induction variable: limits \(0,\?\], increment 1$"
x[i] == // ERROR "Proved IsInBounds$"
y[i] { // ERROR "Proved IsInBounds$"
i--
@@ -686,7 +686,7 @@ func range2(b [][32]int) {
if i < len(b) { // ERROR "Proved Less64$"
println("x")
}
- if i >= 0 { // ERROR "Proved Geq64"
+ if i >= 0 { // ERROR "Proved Geq64$"
println("x")
}
}