aboutsummaryrefslogtreecommitdiff
path: root/test/notinheap.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2018-10-16 15:31:07 -0700
committerMatthew Dempsky <mdempsky@google.com>2018-11-02 19:53:59 +0000
commitb2c397e53798fad7395fa8c67f66d9200d663ae0 (patch)
treef886936cfde34a95b2e110337d5b8c64de9fce26 /test/notinheap.go
parent2764d5ee7b23ae1caf2a4cd4506116a1b9efbf66 (diff)
downloadgo-b2c397e53798fad7395fa8c67f66d9200d663ae0.tar.gz
go-b2c397e53798fad7395fa8c67f66d9200d663ae0.zip
cmd/compile: disallow converting string to notinheap slice
Unlikely to happen in practice, but easy enough to prevent and might as well do so for completeness. Fixes #28243. Change-Id: I848c3af49cb923f088e9490c6a79373e182fad08 Reviewed-on: https://go-review.googlesource.com/c/142719 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'test/notinheap.go')
-rw-r--r--test/notinheap.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/notinheap.go b/test/notinheap.go
index 44b79646ef..16c3f8faf0 100644
--- a/test/notinheap.go
+++ b/test/notinheap.go
@@ -46,10 +46,18 @@ type t1 struct{ x int }
//go:notinheap
type t2 t1
+//go:notinheap
+type t3 byte
+
+//go:notinheap
+type t4 rune
+
var sink interface{}
func i() {
sink = new(t1) // no error
sink = (*t2)(new(t1)) // ERROR "cannot convert(.|\n)*t2 is go:notinheap"
sink = (*t2)(new(struct{ x int })) // ERROR "cannot convert(.|\n)*t2 is go:notinheap"
+ sink = []t3("foo") // ERROR "cannot convert(.|\n)*t3 is go:notinheap"
+ sink = []t4("bar") // ERROR "cannot convert(.|\n)*t4 is go:notinheap"
}