1// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result
2// RUN: cp %s %t
3// RUN: %clang_cc1 -arcmt-modify -triple x86_64-apple-macosx10.6 -x objective-c %t
4// RUN: diff %t %s.result
5// RUN: rm %t
6
7typedef int BOOL;
8
9id IhaveSideEffect();
10
11@protocol NSObject
12- (BOOL)isEqual:(id)object;
13- (id)retain;
14- (oneway void)release;
15@end
16
17@interface NSObject <NSObject> {}
18@end
19
20@interface Foo : NSObject {
21  id bar;
22}
23@property (retain) id bar;
24-(void)test:(id)obj;
25@end
26
27@implementation Foo
28
29@synthesize bar;
30
31-(void)test:(id)obj {
32  id x = self.bar;
33  [x retain];
34  self.bar = obj;
35  // do stuff with x;
36  [x release];
37
38  [IhaveSideEffect() release];
39
40  [x release], x = 0;
41}
42
43@end
44
45void func(Foo *p) {
46  [p release];
47  (([p release]));
48}
49
50@interface Baz {
51	id <NSObject> _foo;
52}
53@end
54
55@implementation Baz
56- (void) dealloc {
57  [_foo release];
58}
59@end
60
61#define RELEASE_MACRO(x) [x release]
62#define RELEASE_MACRO2(x) RELEASE_MACRO(x)
63
64void test2(id p) {
65  RELEASE_MACRO(p);
66  RELEASE_MACRO2(p);
67}
68