Skip to content

Commit d241ea8

Browse files
Jorropomvdan
authored andcommitted
sync/atomic: add missing leak tests for And & Or
Theses tests were forgot because when CL 462298 was originally written And & Or atomics were not available in go. Git were smart enough to rebase over And's & Or's addition. After most reviews and before merging it were pointed I should make theses new intrinsics noescape. When doing this last minute addition I forgot to add tests. Change-Id: I457f98315c0aee91d5743058ab76f256856cb782 Reviewed-on: https://go-review.googlesource.com/c/go/+/633416 Reviewed-by: Keith Randall <[email protected]> Reviewed-by: Keith Randall <[email protected]> Reviewed-by: David Chase <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 4c3aa5d commit d241ea8

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

test/fixedbugs/issue16241.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ func AddUintptr(x *uintptr) { // ERROR "x does not escape$"
1818
atomic.AddUintptr(x, 42)
1919
}
2020

21+
func AndInt32(x *int32) { // ERROR "x does not escape$"
22+
atomic.AndInt32(x, 42)
23+
}
24+
func AndUint32(x *uint32) { // ERROR "x does not escape$"
25+
atomic.AndUint32(x, 42)
26+
}
27+
func AndUintptr(x *uintptr) { // ERROR "x does not escape$"
28+
atomic.AndUintptr(x, 42)
29+
}
30+
2131
func CompareAndSwapInt32(x *int32) { // ERROR "x does not escape$"
2232
atomic.CompareAndSwapInt32(x, 42, 42)
2333
}
@@ -38,6 +48,16 @@ func LoadUintptr(x *uintptr) { // ERROR "x does not escape$"
3848
atomic.LoadUintptr(x)
3949
}
4050

51+
func OrInt32(x *int32) { // ERROR "x does not escape$"
52+
atomic.OrInt32(x, 42)
53+
}
54+
func OrUint32(x *uint32) { // ERROR "x does not escape$"
55+
atomic.OrUint32(x, 42)
56+
}
57+
func OrUintptr(x *uintptr) { // ERROR "x does not escape$"
58+
atomic.OrUintptr(x, 42)
59+
}
60+
4161
func StoreInt32(x *int32) { // ERROR "x does not escape$"
4262
atomic.StoreInt32(x, 42)
4363
}

test/fixedbugs/issue16241_64.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ func AddUint64(x *uint64) { // ERROR "x does not escape$"
1717
atomic.AddUint64(x, 42)
1818
}
1919

20+
func AndInt64(x *int64) { // ERROR "x does not escape$"
21+
atomic.AndInt64(x, 42)
22+
}
23+
func AndUint64(x *uint64) { // ERROR "x does not escape$"
24+
atomic.AndUint64(x, 42)
25+
}
26+
2027
func CompareAndSwapInt64(x *int64) { // ERROR "x does not escape$"
2128
atomic.CompareAndSwapInt64(x, 42, 42)
2229
}
@@ -31,6 +38,13 @@ func LoadUint64(x *uint64) { // ERROR "x does not escape$"
3138
atomic.LoadUint64(x)
3239
}
3340

41+
func OrInt64(x *int64) { // ERROR "x does not escape$"
42+
atomic.OrInt64(x, 42)
43+
}
44+
func OrUint64(x *uint64) { // ERROR "x does not escape$"
45+
atomic.OrUint64(x, 42)
46+
}
47+
3448
func StoreInt64(x *int64) { // ERROR "x does not escape$"
3549
atomic.StoreInt64(x, 42)
3650
}

0 commit comments

Comments
 (0)