Patrick Beard | b2f6820 | 2012-04-06 18:12:22 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fblocks -fsyntax-only -verify -Wno-objc-root-class %s |
Andy Gibbs | 8e8fb3b | 2012-10-19 12:44:48 +0000 | [diff] [blame] | 2 | // expected-no-diagnostics |
Fariborz Jahanian | 636bed1 | 2009-05-21 21:04:28 +0000 | [diff] [blame] | 3 | |
| 4 | @interface NSObject |
| 5 | - (id)self; |
| 6 | - (id)copy; |
| 7 | @end |
| 8 | |
| 9 | typedef 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 | |
| 25 | int 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 | } |