diff options
author | Keith Randall <khr@golang.org> | 2016-09-27 14:39:27 -0700 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2016-09-27 23:54:01 +0000 |
commit | 98938189a16a764007bce7fcd4bfeb2386043208 (patch) | |
tree | 6d4119b0f71b4ab1084e45c01bb7478e166de530 /test/nilptr3.go | |
parent | ba94dd34385af3352660fb4bfa2a2d97fb937088 (diff) | |
download | go-98938189a16a764007bce7fcd4bfeb2386043208.tar.gz go-98938189a16a764007bce7fcd4bfeb2386043208.zip |
cmd/compile: remove duplicate nilchecks
Mark nil check operations as faulting if their arg is zero.
This lets the late nilcheck pass remove duplicates.
Fixes #17242.
Change-Id: I4c9938d8a5a1e43edd85b4a66f0b34004860bcd9
Reviewed-on: https://go-review.googlesource.com/29952
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'test/nilptr3.go')
-rw-r--r-- | test/nilptr3.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/nilptr3.go b/test/nilptr3.go index a97873b97c..b965cd262d 100644 --- a/test/nilptr3.go +++ b/test/nilptr3.go @@ -233,3 +233,17 @@ func c1() { var x Struct func() { x.m() }() // ERROR "removed nil check" } + +type SS struct { + x byte +} + +type TT struct { + SS +} + +func f(t *TT) *byte { + // See issue 17242. + s := &t.SS // ERROR "removed nil check" + return &s.x // ERROR "generated nil check" +} |