aboutsummaryrefslogtreecommitdiff
path: root/test/writebarrier.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/writebarrier.go')
-rw-r--r--test/writebarrier.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/writebarrier.go b/test/writebarrier.go
index 9b741a60df..dcd20a0225 100644
--- a/test/writebarrier.go
+++ b/test/writebarrier.go
@@ -144,3 +144,17 @@ type T8 struct {
func f16(x []T8, y T8) []T8 {
return append(x, y) // ERROR "write barrier"
}
+
+func t1(i interface{}) **int {
+ // From issue 14306, make sure we have write barriers in a type switch
+ // where the assigned variable escapes.
+ switch x := i.(type) { // ERROR "write barrier"
+ case *int:
+ return &x
+ }
+ switch y := i.(type) { // no write barrier here
+ case **int:
+ return y
+ }
+ return nil
+}