diff options
Diffstat (limited to 'test/notinheap2.go')
-rw-r--r-- | test/notinheap2.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/test/notinheap2.go b/test/notinheap2.go index 944f2993ab..de1e6db1d3 100644 --- a/test/notinheap2.go +++ b/test/notinheap2.go @@ -13,12 +13,14 @@ type nih struct { next *nih } -// Globals and stack variables are okay. +// Global variables are okay. var x nih +// Stack variables are not okay. + func f() { - var y nih + var y nih // ERROR "nih is go:notinheap; stack allocation disallowed" x = y } @@ -26,11 +28,17 @@ func f() { var y *nih var z []nih +var w []nih +var n int func g() { y = new(nih) // ERROR "heap allocation disallowed" z = make([]nih, 1) // ERROR "heap allocation disallowed" z = append(z, x) // ERROR "heap allocation disallowed" + // Test for special case of OMAKESLICECOPY + x := make([]nih, n) // ERROR "heap allocation disallowed" + copy(x, z) + z = x } // Writes don't produce write barriers. |