cmd/compile: re-enable nilcheck removal for newobject
Also add compiler debug ouput and add a test.
Fixes #15390.
Change-Id: Iceba1414c29bcc213b87837387bf8ded1f3157f1
Reviewed-on: https://go-review.googlesource.com/30011
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
diff --git a/test/nilptr3.go b/test/nilptr3.go
index b965cd2..8fdae8c 100644
--- a/test/nilptr3.go
+++ b/test/nilptr3.go
@@ -247,3 +247,10 @@
s := &t.SS // ERROR "removed nil check"
return &s.x // ERROR "generated nil check"
}
+
+// make sure not to do nil check for newobject
+func f7() (*Struct, float64) {
+ t := new(Struct)
+ p := &t.Y // ERROR "removed nil check"
+ return t, *p // ERROR "removed nil check"
+}