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// DISABLE: mingw32
5
6#include "Common.h"
7
8@interface A : NSObject {
9@package
10    id object;
11}
12@end
13
14@interface B : NSObject {
15  id _prop;
16  xpc_object_t _xpc_prop;
17}
18- (BOOL)containsSelf:(A*)a;
19@property (retain) id prop;
20@property (retain) xpc_object_t xpc_prop;
21@end
22
23@implementation A
24@end
25
26@implementation B
27- (BOOL)containsSelf:(A*)a {
28    return a->object == self;
29}
30
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}
50@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}
62
63void test(A *prevVal, A *newVal) {
64  [prevVal autorelease];
65  prevVal = [newVal retain];
66}
67
68id test2(A* val) {
69  [[val retain] autorelease];
70  return val;
71}
72
73id test3() {
74  id a = [[A alloc] init];
75  [a autorelease];
76}
77