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