Source file
test/nilcheck.go
1
2
3
4
5
6
7
8
9
10 package p
11
12 type Struct struct {
13 X int
14 Y float64
15 }
16
17 type BigStruct struct {
18 X int
19 Y float64
20 A [1 << 20]int
21 Z string
22 }
23
24 type Empty struct {
25 }
26
27 type Empty1 struct {
28 Empty
29 }
30
31 var (
32 intp *int
33 arrayp *[10]int
34 array0p *[0]int
35 bigarrayp *[1 << 26]int
36 structp *Struct
37 bigstructp *BigStruct
38 emptyp *Empty
39 empty1p *Empty1
40 )
41
42 func f1() {
43 _ = *intp
44 _ = *arrayp
45 _ = *array0p
46 _ = *array0p
47 _ = *intp
48 _ = *arrayp
49 _ = *structp
50 _ = *emptyp
51 _ = *arrayp
52 }
53
54 func f2() {
55 var (
56 intp *int
57 arrayp *[10]int
58 array0p *[0]int
59 bigarrayp *[1 << 20]int
60 structp *Struct
61 bigstructp *BigStruct
62 emptyp *Empty
63 empty1p *Empty1
64 )
65
66 _ = *intp
67 _ = *arrayp
68 _ = *array0p
69 _ = *array0p
70 _ = *intp
71 _ = *arrayp
72 _ = *structp
73 _ = *emptyp
74 _ = *arrayp
75 _ = *bigarrayp
76 _ = *bigstructp
77 _ = *empty1p
78 }
79
80 func fx10k() *[10000]int
81
82 var b bool
83
84 func f3(x *[10000]int) {
85
86
87 _ = x[9999]
88
89 for {
90 if x[9999] != 0 {
91 break
92 }
93 }
94
95 x = fx10k()
96 _ = x[9999]
97 if b {
98 _ = x[9999]
99 } else {
100 _ = x[9999]
101 }
102 _ = x[9999]
103
104 x = fx10k()
105 if b {
106 _ = x[9999]
107 } else {
108 _ = x[9999]
109 }
110 _ = x[9999]
111
112 fx10k()
113
114
115
116
117 _ = x[9999]
118 }
119
120 func f3a() {
121 x := fx10k()
122 y := fx10k()
123 z := fx10k()
124 _ = &x[9]
125 y = z
126 _ = &x[9]
127 x = y
128 _ = &x[9]
129 }
130
131 func f3b() {
132 x := fx10k()
133 y := fx10k()
134 _ = &x[9]
135 y = x
136 _ = &x[9]
137 x = y
138 _ = &x[9]
139 }
140
141 func fx10() *[10]int
142
143 func f4(x *[10]int) {
144
145
146
147
148 _ = x[9]
149
150 for {
151 if x[9] != 0 {
152 break
153 }
154 }
155
156 x = fx10()
157 _ = x[9]
158 if b {
159 _ = x[9]
160 } else {
161 _ = x[9]
162 }
163 _ = x[9]
164
165 x = fx10()
166 if b {
167 _ = x[9]
168 } else {
169 _ = &x[9]
170 }
171 _ = x[9]
172
173 fx10()
174 _ = x[9]
175
176 x = fx10()
177 y := fx10()
178 _ = &x[9]
179 y = x
180 _ = &x[9]
181 x = y
182 _ = &x[9]
183 }
184
185 func f5(m map[string]struct{}) bool {
186
187 tmp1, tmp2 := m[""]
188 _, ok := tmp1, tmp2
189 return ok
190 }
191
View as plain text