blob: 543bcf6632af83f1aef55ec388ee63f2143fa1a4 [file] [log] [blame]
John McCalld1e40d52011-10-02 01:16:38 +00001// 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
John McCall8f0e8d22011-06-15 23:25:17 +00003// RUN: diff %t %s.result
Argyrios Kyrtzidisd8b42162012-01-12 02:34:32 +00004// DISABLE: mingw32
John McCall8f0e8d22011-06-15 23:25:17 +00005
Argyrios Kyrtzidis1b8fbd32012-05-23 21:50:04 +00006#include "Common.h"
John McCall8f0e8d22011-06-15 23:25:17 +00007
John McCall8f0e8d22011-06-15 23:25:17 +00008@interface A : NSObject {
9@package
10 id object;
11}
12@end
13
Argyrios Kyrtzidis1b8fbd32012-05-23 21:50:04 +000014@interface B : NSObject {
15 id _prop;
16 xpc_object_t _xpc_prop;
17}
John McCall8f0e8d22011-06-15 23:25:17 +000018- (BOOL)containsSelf:(A*)a;
Argyrios Kyrtzidis1b8fbd32012-05-23 21:50:04 +000019@property (retain) id prop;
20@property (retain) xpc_object_t xpc_prop;
John McCall8f0e8d22011-06-15 23:25:17 +000021@end
22
23@implementation A
24@end
25
26@implementation B
27- (BOOL)containsSelf:(A*)a {
28 return a->object == self;
29}
Argyrios Kyrtzidis1b8fbd32012-05-23 21:50:04 +000030
31-(id) prop {
32 return _prop;
33}
34-(void) setProp:(id) newVal {
35 [_prop autorelease];
36 _prop = [newVal retain];
37}
38-(void) setProp2:(CFTypeRef) newVal {
39 [_prop autorelease];
40 _prop = (id)CFRetain(newVal);
41}
42
43-(id) xpc_prop {
44 return _xpc_prop;
45}
46-(void) setXpc_prop:(xpc_object_t) newVal {
47 [_xpc_prop autorelease];
48 _xpc_prop = xpc_retain(newVal);
49}
John McCall8f0e8d22011-06-15 23:25:17 +000050@end
51
52void NSLog(id, ...);
53
54int main (int argc, const char * argv[]) {
55 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
56 A *a = [[A new] autorelease];
57 B *b = [[B new] autorelease];
58 NSLog(@"%s", [b containsSelf:a] ? "YES" : "NO");
59 [pool drain];
60 return 0;
61}
Argyrios Kyrtzidis1b8fbd32012-05-23 21:50:04 +000062
63void test(A *prevVal, A *newVal) {
64 [prevVal autorelease];
65 prevVal = [newVal retain];
66}
Argyrios Kyrtzidisaf1c08f2013-01-04 18:29:59 +000067
68id test2(A* val) {
69 [[val retain] autorelease];
70 return val;
71}
Argyrios Kyrtzidis20bcd4e2013-01-04 18:30:11 +000072
73id test3() {
74 id a = [[A alloc] init];
75 [a autorelease];
76}