1// errorcheck
2
3// Copyright 2013 The Go Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file.
6
7// issue 4232
8// issue 7200
9
10package p
11
12func f() {
13	var a [10]int
14	_ = a[-1]  // ERROR "invalid array index -1|index out of bounds|must not be negative"
15	_ = a[-1:] // ERROR "invalid slice index -1|index out of bounds|must not be negative"
16	_ = a[:-1] // ERROR "invalid slice index -1|index out of bounds|must not be negative"
17	_ = a[10]  // ERROR "invalid array index 10|index .*out of bounds"
18	_ = a[9:10]
19	_ = a[10:10]
20	_ = a[9:12]            // ERROR "invalid slice index 12|index .*out of bounds"
21	_ = a[11:12]           // ERROR "invalid slice index 11|index .*out of bounds"
22	_ = a[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow|invalid slice index 1 << 100|index out of bounds"
23
24	var s []int
25	_ = s[-1]  // ERROR "invalid slice index -1|index .*out of bounds|must not be negative"
26	_ = s[-1:] // ERROR "invalid slice index -1|index .*out of bounds|must not be negative"
27	_ = s[:-1] // ERROR "invalid slice index -1|index .*out of bounds|must not be negative"
28	_ = s[10]
29	_ = s[9:10]
30	_ = s[10:10]
31	_ = s[9:12]
32	_ = s[11:12]
33	_ = s[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow|invalid slice index 1 << 100|index out of bounds"
34
35	const c = "foofoofoof"
36	_ = c[-1]  // ERROR "invalid string index -1|index out of bounds|must not be negative"
37	_ = c[-1:] // ERROR "invalid slice index -1|index out of bounds|must not be negative"
38	_ = c[:-1] // ERROR "invalid slice index -1|index out of bounds|must not be negative"
39	_ = c[10]  // ERROR "invalid string index 10|index .*out of bounds"
40	_ = c[9:10]
41	_ = c[10:10]
42	_ = c[9:12]            // ERROR "invalid slice index 12|index .*out of bounds"
43	_ = c[11:12]           // ERROR "invalid slice index 11|index .*out of bounds"
44	_ = c[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow|invalid slice index 1 << 100|index out of bounds"
45
46	var t string
47	_ = t[-1]  // ERROR "invalid string index -1|index out of bounds|must not be negative"
48	_ = t[-1:] // ERROR "invalid slice index -1|index out of bounds|must not be negative"
49	_ = t[:-1] // ERROR "invalid slice index -1|index out of bounds|must not be negative"
50	_ = t[10]
51	_ = t[9:10]
52	_ = t[10:10]
53	_ = t[9:12]
54	_ = t[11:12]
55	_ = t[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow|invalid slice index 1 << 100|index out of bounds"
56}
57