2 // TEST_CFLAGS -framework CoreFoundation -Weverything
4 #pragma clang diagnostic push
5 #pragma clang diagnostic ignored "-Weverything"
7 #pragma clang diagnostic pop
8 #include <objc/NSObject.h>
9 #include <objc/objc-internal.h>
10 #include <CoreFoundation/CoreFoundation.h>
13 // Some warnings just aren't feasible to work around. We'll disable them instead.
14 #pragma clang diagnostic ignored "-Watomic-implicit-seq-cst"
15 #pragma clang diagnostic ignored "-Wdirect-ivar-access"
16 #pragma clang diagnostic ignored "-Wold-style-cast"
18 static int deallocCount;
19 @interface Refcnt: NSObject @end
20 @implementation Refcnt {
24 _OBJC_SUPPORTED_INLINE_REFCNT(_rc)
33 @interface MainRefcnt: NSObject @end
34 @implementation MainRefcnt {
38 _OBJC_SUPPORTED_INLINE_REFCNT_WITH_DEALLOC2MAIN(_rc)
41 testassert(pthread_main_np());
50 Refcnt *obj = [Refcnt new];
58 testassert(deallocCount == 1);
60 MainRefcnt *obj2 = [MainRefcnt new];
65 dispatch_group_t group = dispatch_group_create();
66 dispatch_group_async(group, dispatch_get_global_queue(0, 0), ^{
69 dispatch_group_async(group, dispatch_get_global_queue(0, 0), ^{
72 dispatch_group_async(group, dispatch_get_global_queue(0, 0), ^{
75 dispatch_group_async(group, dispatch_get_global_queue(0, 0), ^{
79 dispatch_group_notify(group, dispatch_get_main_queue(), ^{
80 testassert(deallocCount == 2);