1 // errorcheck -+ -p=runtime
3 // Copyright 2016 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // Test go:nowritebarrier and related directives.
8 // This must appear to be in package runtime so the compiler
9 // recognizes "systemstack".
22 x.f = y // ERROR "write barrier prohibited"
31 //go:nowritebarrierrec
38 x.f = y // ERROR "write barrier prohibited by caller"
41 // Test recursive cycles through nowritebarrierrec and yeswritebarrierrec.
43 //go:nowritebarrierrec
48 //go:yeswritebarrierrec
58 //go:nowritebarrierrec
63 //go:nowritebarrierrec
74 x.f = y // ERROR "write barrier prohibited by caller"
78 //go:yeswritebarrierrec
84 func systemstack(func()) {}
86 //go:nowritebarrierrec
90 x.f = y // ERROR "write barrier prohibited by caller"
95 x.f = y // ERROR "write barrier prohibited by caller"