mirror of
https://github.com/golang/go
synced 2024-11-22 14:44:50 -07:00
test: gofmt bounds.go
Change-Id: I8b462e20064658120afc8eb1cbac926254d1e24e Reviewed-on: https://go-review.googlesource.com/114937 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
6070e432d2
commit
002c764533
@ -12,23 +12,23 @@ package foo
|
||||
var (
|
||||
s []int
|
||||
|
||||
a1 [1]int
|
||||
a1k [1000]int
|
||||
a1 [1]int
|
||||
a1k [1000]int
|
||||
a100k [100000]int
|
||||
|
||||
p1 *[1]int
|
||||
p1k *[1000]int
|
||||
p1 *[1]int
|
||||
p1k *[1000]int
|
||||
p100k *[100000]int
|
||||
|
||||
i int
|
||||
ui uint
|
||||
i8 int8
|
||||
ui8 uint8
|
||||
i16 int16
|
||||
i int
|
||||
ui uint
|
||||
i8 int8
|
||||
ui8 uint8
|
||||
i16 int16
|
||||
ui16 uint16
|
||||
i32 int32
|
||||
i32 int32
|
||||
ui32 uint32
|
||||
i64 int64
|
||||
i64 int64
|
||||
ui64 uint64
|
||||
)
|
||||
|
||||
@ -61,11 +61,11 @@ func main() {
|
||||
// Unsigned 8-bit numbers don't need checks for len >= 2⁸.
|
||||
use(s[ui8])
|
||||
use(a1[ui8])
|
||||
use(a1k[ui8]) // ERROR "index bounds check elided"
|
||||
use(a100k[ui8]) // ERROR "index bounds check elided"
|
||||
use(a1k[ui8]) // ERROR "index bounds check elided"
|
||||
use(a100k[ui8]) // ERROR "index bounds check elided"
|
||||
use(p1[ui8])
|
||||
use(p1k[ui8]) // ERROR "index bounds check elided"
|
||||
use(p100k[ui8]) // ERROR "index bounds check elided"
|
||||
use(p1k[ui8]) // ERROR "index bounds check elided"
|
||||
use(p100k[ui8]) // ERROR "index bounds check elided"
|
||||
|
||||
use(s[i16])
|
||||
use(a1[i16])
|
||||
@ -79,10 +79,10 @@ func main() {
|
||||
use(s[ui16])
|
||||
use(a1[ui16])
|
||||
use(a1k[ui16])
|
||||
use(a100k[ui16]) // ERROR "index bounds check elided"
|
||||
use(a100k[ui16]) // ERROR "index bounds check elided"
|
||||
use(p1[ui16])
|
||||
use(p1k[ui16])
|
||||
use(p100k[ui16]) // ERROR "index bounds check elided"
|
||||
use(p100k[ui16]) // ERROR "index bounds check elided"
|
||||
|
||||
use(s[i32])
|
||||
use(a1[i32])
|
||||
@ -128,11 +128,11 @@ func main() {
|
||||
|
||||
use(s[ui%999])
|
||||
use(a1[ui%999])
|
||||
use(a1k[ui%999]) // ERROR "index bounds check elided"
|
||||
use(a100k[ui%999]) // ERROR "index bounds check elided"
|
||||
use(a1k[ui%999]) // ERROR "index bounds check elided"
|
||||
use(a100k[ui%999]) // ERROR "index bounds check elided"
|
||||
use(p1[ui%999])
|
||||
use(p1k[ui%999]) // ERROR "index bounds check elided"
|
||||
use(p100k[ui%999]) // ERROR "index bounds check elided"
|
||||
use(p1k[ui%999]) // ERROR "index bounds check elided"
|
||||
use(p100k[ui%999]) // ERROR "index bounds check elided"
|
||||
|
||||
use(s[i%1000])
|
||||
use(a1[i%1000])
|
||||
@ -144,11 +144,11 @@ func main() {
|
||||
|
||||
use(s[ui%1000])
|
||||
use(a1[ui%1000])
|
||||
use(a1k[ui%1000]) // ERROR "index bounds check elided"
|
||||
use(a100k[ui%1000]) // ERROR "index bounds check elided"
|
||||
use(a1k[ui%1000]) // ERROR "index bounds check elided"
|
||||
use(a100k[ui%1000]) // ERROR "index bounds check elided"
|
||||
use(p1[ui%1000])
|
||||
use(p1k[ui%1000]) // ERROR "index bounds check elided"
|
||||
use(p100k[ui%1000]) // ERROR "index bounds check elided"
|
||||
use(p1k[ui%1000]) // ERROR "index bounds check elided"
|
||||
use(p100k[ui%1000]) // ERROR "index bounds check elided"
|
||||
|
||||
use(s[i%1001])
|
||||
use(a1[i%1001])
|
||||
@ -161,45 +161,45 @@ func main() {
|
||||
use(s[ui%1001])
|
||||
use(a1[ui%1001])
|
||||
use(a1k[ui%1001])
|
||||
use(a100k[ui%1001]) // ERROR "index bounds check elided"
|
||||
use(a100k[ui%1001]) // ERROR "index bounds check elided"
|
||||
use(p1[ui%1001])
|
||||
use(p1k[ui%1001])
|
||||
use(p100k[ui%1001]) // ERROR "index bounds check elided"
|
||||
use(p100k[ui%1001]) // ERROR "index bounds check elided"
|
||||
|
||||
// Bitwise and truncates the maximum value to the mask value.
|
||||
// The result (for a positive mask) cannot be negative, so elision
|
||||
// applies to both signed and unsigned indexes.
|
||||
use(s[i&999])
|
||||
use(a1[i&999])
|
||||
use(a1k[i&999]) // ERROR "index bounds check elided"
|
||||
use(a100k[i&999]) // ERROR "index bounds check elided"
|
||||
use(a1k[i&999]) // ERROR "index bounds check elided"
|
||||
use(a100k[i&999]) // ERROR "index bounds check elided"
|
||||
use(p1[i&999])
|
||||
use(p1k[i&999]) // ERROR "index bounds check elided"
|
||||
use(p100k[i&999]) // ERROR "index bounds check elided"
|
||||
use(p1k[i&999]) // ERROR "index bounds check elided"
|
||||
use(p100k[i&999]) // ERROR "index bounds check elided"
|
||||
|
||||
use(s[ui&999])
|
||||
use(a1[ui&999])
|
||||
use(a1k[ui&999]) // ERROR "index bounds check elided"
|
||||
use(a100k[ui&999]) // ERROR "index bounds check elided"
|
||||
use(a1k[ui&999]) // ERROR "index bounds check elided"
|
||||
use(a100k[ui&999]) // ERROR "index bounds check elided"
|
||||
use(p1[ui&999])
|
||||
use(p1k[ui&999]) // ERROR "index bounds check elided"
|
||||
use(p100k[ui&999]) // ERROR "index bounds check elided"
|
||||
use(p1k[ui&999]) // ERROR "index bounds check elided"
|
||||
use(p100k[ui&999]) // ERROR "index bounds check elided"
|
||||
|
||||
use(s[i&1000])
|
||||
use(a1[i&1000])
|
||||
use(a1k[i&1000])
|
||||
use(a100k[i&1000]) // ERROR "index bounds check elided"
|
||||
use(a100k[i&1000]) // ERROR "index bounds check elided"
|
||||
use(p1[i&1000])
|
||||
use(p1k[i&1000])
|
||||
use(p100k[i&1000]) // ERROR "index bounds check elided"
|
||||
use(p100k[i&1000]) // ERROR "index bounds check elided"
|
||||
|
||||
use(s[ui&1000])
|
||||
use(a1[ui&1000])
|
||||
use(a1k[ui&1000])
|
||||
use(a100k[ui&1000]) // ERROR "index bounds check elided"
|
||||
use(a100k[ui&1000]) // ERROR "index bounds check elided"
|
||||
use(p1[ui&1000])
|
||||
use(p1k[ui&1000])
|
||||
use(p100k[ui&1000]) // ERROR "index bounds check elided"
|
||||
use(p100k[ui&1000]) // ERROR "index bounds check elided"
|
||||
|
||||
// Right shift cuts the effective number of bits in the index,
|
||||
// but only for unsigned (signed stays negative).
|
||||
@ -214,10 +214,10 @@ func main() {
|
||||
use(s[ui32>>22])
|
||||
use(a1[ui32>>22])
|
||||
use(a1k[ui32>>22])
|
||||
use(a100k[ui32>>22]) // ERROR "index bounds check elided"
|
||||
use(a100k[ui32>>22]) // ERROR "index bounds check elided"
|
||||
use(p1[ui32>>22])
|
||||
use(p1k[ui32>>22])
|
||||
use(p100k[ui32>>22]) // ERROR "index bounds check elided"
|
||||
use(p100k[ui32>>22]) // ERROR "index bounds check elided"
|
||||
|
||||
use(s[i32>>23])
|
||||
use(a1[i32>>23])
|
||||
@ -229,11 +229,11 @@ func main() {
|
||||
|
||||
use(s[ui32>>23])
|
||||
use(a1[ui32>>23])
|
||||
use(a1k[ui32>>23]) // ERROR "index bounds check elided"
|
||||
use(a100k[ui32>>23]) // ERROR "index bounds check elided"
|
||||
use(a1k[ui32>>23]) // ERROR "index bounds check elided"
|
||||
use(a100k[ui32>>23]) // ERROR "index bounds check elided"
|
||||
use(p1[ui32>>23])
|
||||
use(p1k[ui32>>23]) // ERROR "index bounds check elided"
|
||||
use(p100k[ui32>>23]) // ERROR "index bounds check elided"
|
||||
use(p1k[ui32>>23]) // ERROR "index bounds check elided"
|
||||
use(p100k[ui32>>23]) // ERROR "index bounds check elided"
|
||||
|
||||
// Division cuts the range like right shift does.
|
||||
use(s[i/1e6])
|
||||
@ -263,7 +263,7 @@ func main() {
|
||||
use(p1[ui/1e7])
|
||||
}
|
||||
|
||||
var sum int
|
||||
var sum int
|
||||
|
||||
func use(x int) {
|
||||
sum += x
|
||||
|
Loading…
Reference in New Issue
Block a user