xref: /aosp_15_r20/external/clang/test/ARCMT/GC-check.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 -fobjc-gc-only %s
2*67e74705SXin Li// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 -fobjc-gc-only -x objective-c++ %s
3*67e74705SXin Li
4*67e74705SXin Li#define CF_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode")))
5*67e74705SXin Litypedef unsigned NSUInteger;
6*67e74705SXin Litypedef const void * CFTypeRef;
7*67e74705SXin LiCFTypeRef CFMakeCollectable(CFTypeRef cf) CF_AUTOMATED_REFCOUNT_UNAVAILABLE; // expected-note {{unavailable}}
8*67e74705SXin Livoid *__strong NSAllocateCollectable(NSUInteger size, NSUInteger options);
9*67e74705SXin Li
10*67e74705SXin Livoid test1(CFTypeRef *cft) {
11*67e74705SXin Li  CFTypeRef c = CFMakeCollectable(cft); // expected-error {{CFMakeCollectable will leak the object that it receives in ARC}} \
12*67e74705SXin Li                // expected-error {{unavailable}}
13*67e74705SXin Li  NSAllocateCollectable(100, 0); // expected-error {{call returns pointer to GC managed memory; it will become unmanaged in ARC}}
14*67e74705SXin Li}
15*67e74705SXin Li
16*67e74705SXin Li@interface I1 {
17*67e74705SXin Li  __strong void *gcVar; // expected-error {{GC managed memory will become unmanaged in ARC}}
18*67e74705SXin Li}
19*67e74705SXin Li@end;
20