llvm-project
75 строк · 1.4 Кб
1// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
2// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
3// RUN: diff %t %s.result
4
5#include "Common.h"
6
7@interface A : NSObject {
8@package
9id object;
10}
11@end
12
13@interface B : NSObject {
14id _prop;
15xpc_object_t _xpc_prop;
16}
17- (BOOL)containsSelf:(A*)a;
18@property (retain) id prop;
19@property (retain) xpc_object_t xpc_prop;
20@end
21
22@implementation A
23@end
24
25@implementation B
26- (BOOL)containsSelf:(A*)a {
27return a->object == self;
28}
29
30-(id) prop {
31return _prop;
32}
33-(void) setProp:(id) newVal {
34[_prop autorelease];
35_prop = [newVal retain];
36}
37-(void) setProp2:(CFTypeRef) newVal {
38[_prop autorelease];
39_prop = (id)CFRetain(newVal);
40}
41
42-(id) xpc_prop {
43return _xpc_prop;
44}
45-(void) setXpc_prop:(xpc_object_t) newVal {
46[_xpc_prop autorelease];
47_xpc_prop = xpc_retain(newVal);
48}
49@end
50
51void NSLog(id, ...);
52
53int main (int argc, const char * argv[]) {
54NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
55A *a = [[A new] autorelease];
56B *b = [[B new] autorelease];
57NSLog(@"%s", [b containsSelf:a] ? "YES" : "NO");
58[pool drain];
59return 0;
60}
61
62void test(A *prevVal, A *newVal) {
63[prevVal autorelease];
64prevVal = [newVal retain];
65}
66
67id test2(A* val) {
68[[val retain] autorelease];
69return val;
70}
71
72id test3(void) {
73id a = [[A alloc] init];
74[a autorelease];
75}
76