blob: 4a75f5ce8efa2cdeba37da0e2b757f23824b9640 [file] [log] [blame]
Patrick Beardb2f68202012-04-06 18:12:22 +00001// RUN: %clang_cc1 -fblocks -fsyntax-only -verify -Wno-objc-root-class %s
Andy Gibbs8e8fb3b2012-10-19 12:44:48 +00002// expected-no-diagnostics
Fariborz Jahanian636bed12009-05-21 21:04:28 +00003
4@interface NSObject
5- (id)self;
6- (id)copy;
7@end
8
9typedef struct _foo *__attribute__((NSObject)) Foo_ref;
10
11@interface TestObject {
12 Foo_ref dict;
13}
14@property(retain) Foo_ref dict;
15@end
16
17@implementation TestObject
18@synthesize dict;
19@end
20
21@interface NSDictionary
22- (int)retainCount;
23@end
24
25int main(int argc, char *argv[]) {
26 NSDictionary *dictRef;
27 Foo_ref foo = (Foo_ref)dictRef;
28
29 // do Properties retain?
30 int before = [dictRef retainCount];
31 int after = [dictRef retainCount];
32
33 if ([foo retainCount] != [dictRef retainCount]) {
34 }
35
36 // do Blocks retain?
37 {
38 void (^block)(void) = ^{
39 [foo self];
40 };
41 before = [foo retainCount];
42 id save = [block copy];
43 after = [foo retainCount];
44 if (after <= before) {
45 ;
46 }
47 }
48 return 0;
49}