]> Cypherpunks.ru repositories - gostls13.git/blob - test/prove.go
Merge "[dev.ssa] Merge remote-tracking branch 'origin/master' into ssamerge" into...
[gostls13.git] / test / prove.go
1 // +build amd64
2 // errorcheck -0 -d=ssa/prove/debug=3
3
4 package main
5
6 func f0(a []int) int {
7         a[0] = 1
8         a[0] = 1 // ERROR "Proved IsInBounds$"
9         a[6] = 1
10         a[6] = 1 // ERROR "Proved IsInBounds$"
11         a[5] = 1
12         a[5] = 1 // ERROR "Proved IsInBounds$"
13         return 13
14 }
15
16 func f1(a []int) int {
17         if len(a) <= 5 {
18                 return 18
19         }
20         a[0] = 1
21         a[0] = 1 // ERROR "Proved IsInBounds$"
22         a[6] = 1
23         a[6] = 1 // ERROR "Proved IsInBounds$"
24         a[5] = 1 // ERROR "Proved constant IsInBounds$"
25         a[5] = 1 // ERROR "Proved IsInBounds$"
26         return 26
27 }
28
29 func f2(a []int) int {
30         for i := range a {
31                 a[i] = i
32                 a[i] = i // ERROR "Proved IsInBounds$"
33         }
34         return 34
35 }
36
37 func f3(a []uint) int {
38         for i := uint(0); i < uint(len(a)); i++ {
39                 a[i] = i // ERROR "Proved IsInBounds$"
40         }
41         return 41
42 }
43
44 func f4a(a, b, c int) int {
45         if a < b {
46                 if a == b { // ERROR "Disproved Eq64$"
47                         return 47
48                 }
49                 if a > b { // ERROR "Disproved Greater64$"
50                         return 50
51                 }
52                 if a < b { // ERROR "Proved Less64$"
53                         return 53
54                 }
55                 if a == b { // ERROR "Disproved Eq64$"
56                         return 56
57                 }
58                 if a > b {
59                         return 59
60                 }
61                 return 61
62         }
63         return 63
64 }
65
66 func f4b(a, b, c int) int {
67         if a <= b {
68                 if a >= b {
69                         if a == b { // ERROR "Proved Eq64$"
70                                 return 70
71                         }
72                         return 75
73                 }
74                 return 77
75         }
76         return 79
77 }
78
79 func f4c(a, b, c int) int {
80         if a <= b {
81                 if a >= b {
82                         if a != b { // ERROR "Disproved Neq64$"
83                                 return 73
84                         }
85                         return 75
86                 }
87                 return 77
88         }
89         return 79
90 }
91
92 func f4d(a, b, c int) int {
93         if a < b {
94                 if a < c {
95                         if a < b { // ERROR "Proved Less64$"
96                                 if a < c { // ERROR "Proved Less64$"
97                                         return 87
98                                 }
99                                 return 89
100                         }
101                         return 91
102                 }
103                 return 93
104         }
105         return 95
106 }
107
108 func f4e(a, b, c int) int {
109         if a < b {
110                 if b > a { // ERROR "Proved Greater64$"
111                         return 101
112                 }
113                 return 103
114         }
115         return 105
116 }
117
118 func f4f(a, b, c int) int {
119         if a <= b {
120                 if b > a {
121                         if b == a { // ERROR "Disproved Eq64$"
122                                 return 112
123                         }
124                         return 114
125                 }
126                 if b >= a { // ERROR "Proved Geq64$"
127                         if b == a { // ERROR "Proved Eq64$"
128                                 return 118
129                         }
130                         return 120
131                 }
132                 return 122
133         }
134         return 124
135 }
136
137 func f5(a, b uint) int {
138         if a == b {
139                 if a <= b { // ERROR "Proved Leq64U$"
140                         return 130
141                 }
142                 return 132
143         }
144         return 134
145 }
146
147 // These comparisons are compile time constants.
148 func f6a(a uint8) int {
149         if a < a { // ERROR "Disproved Less8U$"
150                 return 140
151         }
152         return 151
153 }
154
155 func f6b(a uint8) int {
156         if a < a { // ERROR "Disproved Less8U$"
157                 return 140
158         }
159         return 151
160 }
161
162 func f6x(a uint8) int {
163         if a > a { // ERROR "Disproved Greater8U$"
164                 return 143
165         }
166         return 151
167 }
168
169 func f6d(a uint8) int {
170         if a <= a { // ERROR "Proved Leq8U$"
171                 return 146
172         }
173         return 151
174 }
175
176 func f6e(a uint8) int {
177         if a >= a { // ERROR "Proved Geq8U$"
178                 return 149
179         }
180         return 151
181 }
182
183 func f7(a []int, b int) int {
184         if b < len(a) {
185                 a[b] = 3
186                 if b < len(a) { // ERROR "Proved Less64$"
187                         a[b] = 5 // ERROR "Proved IsInBounds$"
188                 }
189         }
190         return 161
191 }
192
193 func f8(a, b uint) int {
194         if a == b {
195                 return 166
196         }
197         if a > b {
198                 return 169
199         }
200         if a < b { // ERROR "Proved Less64U$"
201                 return 172
202         }
203         return 174
204 }
205
206 func main() {
207 }