From 04e76f295f434bf1bd5ef3b01eed42b638a8b321 Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Wed, 17 Aug 2016 10:32:39 -0400 Subject: [PATCH] test: add test for CL 26831 Test nil check removal for access of PAUTOHEAP. Change-Id: Id739a9cda7cd3ff173bdcccfedcad93ee90711ef Reviewed-on: https://go-review.googlesource.com/27232 Run-TryBot: Cherry Zhang Reviewed-by: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- test/nilptr3.go | 8 ++++++++ test/nilptr3_ssa.go | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/test/nilptr3.go b/test/nilptr3.go index a81efb7d8e..73e074391b 100644 --- a/test/nilptr3.go +++ b/test/nilptr3.go @@ -214,3 +214,11 @@ func p1() byte { p := new([100]byte) return p[5] // ERROR "removed nil check" } + +// make sure not to do nil check for access of PAUTOHEAP +//go:noinline +func (p *Struct) m() {} +func c1() { + var x Struct + func() { x.m() }() // ERROR "removed nil check" +} diff --git a/test/nilptr3_ssa.go b/test/nilptr3_ssa.go index 0974a84333..af1186579e 100644 --- a/test/nilptr3_ssa.go +++ b/test/nilptr3_ssa.go @@ -226,3 +226,11 @@ func p1() byte { p := new([100]byte) return p[5] // ERROR "removed nil check" } + +// make sure not to do nil check for access of PAUTOHEAP +//go:noinline +func (p *Struct) m() {} +func c1() { + var x Struct + func() { x.m() }() // ERROR "removed nil check" +} -- 2.48.1