Source file test/nilptr5.go
1 // errorcheck -0 -d=nil 2 3 //go:build !wasm && !aix 4 // +build !wasm,!aix 5 6 // Copyright 2018 The Go Authors. All rights reserved. 7 // Use of this source code is governed by a BSD-style 8 // license that can be found in the LICENSE file. 9 10 // Test that nil checks are removed. 11 // Optimization is enabled. 12 13 package p 14 15 func f5(p *float32, q *float64, r *float32, s *float64) float64 { 16 x := float64(*p) // ERROR "removed nil check" 17 y := *q // ERROR "removed nil check" 18 *r = 7 // ERROR "removed nil check" 19 *s = 9 // ERROR "removed nil check" 20 return x + y 21 } 22 23 type T struct{ b [29]byte } 24 25 func f6(p, q *T) { 26 x := *p // ERROR "removed nil check" 27 *q = x // ERROR "removed nil check" 28 } 29 30 // make sure to remove nil check for memory move (issue #18003) 31 func f8(t *struct{ b [8]int }) struct{ b [8]int } { 32 return *t // ERROR "removed nil check" 33 } 34