1*f4a2713aSLionel Sambuc// RUN: not %clang_cc1 -fsyntax-only -fblocks -fobjc-arc -Wno-objc-root-class %s 2>&1 | FileCheck --check-prefix=CHECK-ARC %s 2*f4a2713aSLionel Sambuc// rdar://9829425 3*f4a2713aSLionel Sambuc 4*f4a2713aSLionel Sambuc// RUN: not %clang_cc1 -fsyntax-only -fblocks -Wno-objc-root-class %s 2>&1 | FileCheck %s 5*f4a2713aSLionel Sambuc// rdar://11761511 6*f4a2713aSLionel Sambuc 7*f4a2713aSLionel Sambucextern void doSomething(); 8*f4a2713aSLionel Sambuc 9*f4a2713aSLionel Sambuc@interface Test 10*f4a2713aSLionel Sambuc{ 11*f4a2713aSLionel Sambuc@public 12*f4a2713aSLionel Sambuc void (^aBlock)(void); 13*f4a2713aSLionel Sambuc} 14*f4a2713aSLionel Sambuc@property (retain) void (^aBlock)(void); 15*f4a2713aSLionel Sambuc@property (weak, retain) void (^aBlockW)(void); 16*f4a2713aSLionel Sambuc@property (strong, retain) void (^aBlockS)(void); // OK 17*f4a2713aSLionel Sambuc@property (readonly, retain) void (^aBlockR)(void); // OK 18*f4a2713aSLionel Sambuc@property (copy, retain) void (^aBlockC)(void); 19*f4a2713aSLionel Sambuc@property (assign, retain) void (^aBlockA)(void); 20*f4a2713aSLionel Sambuc@end 21*f4a2713aSLionel Sambuc 22*f4a2713aSLionel Sambuc@implementation Test 23*f4a2713aSLionel Sambuc@synthesize aBlock; 24*f4a2713aSLionel Sambuc@dynamic aBlockW, aBlockS, aBlockR, aBlockC, aBlockA; 25*f4a2713aSLionel Sambuc@end 26*f4a2713aSLionel Sambuc 27*f4a2713aSLionel Sambucint main() { 28*f4a2713aSLionel Sambuc Test *t; 29*f4a2713aSLionel Sambuc t.aBlock = ^{ doSomething(); }; 30*f4a2713aSLionel Sambuc t.aBlockW = ^{ doSomething(); }; 31*f4a2713aSLionel Sambuc t.aBlockS = ^{ doSomething(); }; 32*f4a2713aSLionel Sambuc} 33*f4a2713aSLionel Sambuc 34*f4a2713aSLionel Sambuc// CHECK-ARC: 14:1: warning: retain'ed block property does not copy the block - use copy attribute instead 35*f4a2713aSLionel Sambuc// CHECK-ARC: @property (retain) void (^aBlock)(void); 36*f4a2713aSLionel Sambuc// CHECK-ARC: ^ 37*f4a2713aSLionel Sambuc// CHECK-ARC: 15:1: error: property attributes 'retain' and 'weak' are mutually exclusive 38*f4a2713aSLionel Sambuc// CHECK-ARC: @property (weak, retain) void (^aBlockW)(void); 39*f4a2713aSLionel Sambuc// CHECK-ARC: ^ 40*f4a2713aSLionel Sambuc// CHECK-ARC: 18:1: error: property attributes 'copy' and 'retain' are mutually exclusive 41*f4a2713aSLionel Sambuc// CHECK-ARC: @property (copy, retain) void (^aBlockC)(void); 42*f4a2713aSLionel Sambuc// CHECK-ARC: ^ 43*f4a2713aSLionel Sambuc// CHECK-ARC: 19:1: error: property attributes 'assign' and 'retain' are mutually exclusive 44*f4a2713aSLionel Sambuc// CHECK-ARC: @property (assign, retain) void (^aBlockA)(void); 45*f4a2713aSLionel Sambuc// CHECK-ARC: ^ 46*f4a2713aSLionel Sambuc// CHECK-ARC: 30:13: warning: assigning block literal to a weak property; object will be released after assignment 47*f4a2713aSLionel Sambuc// CHECK-ARC: t.aBlockW = ^{ doSomething(); }; 48*f4a2713aSLionel Sambuc// CHECK-ARC: ^ ~~~~~~~~~~~~~~~~~~~ 49*f4a2713aSLionel Sambuc// CHECK-ARC: 2 warnings and 3 errors generated. 50*f4a2713aSLionel Sambuc 51*f4a2713aSLionel Sambuc// CHECK: 14:1: warning: retain'ed block property does not copy the block - use copy attribute instead 52*f4a2713aSLionel Sambuc// CHECK: @property (retain) void (^aBlock)(void); 53*f4a2713aSLionel Sambuc// CHECK: ^ 54*f4a2713aSLionel Sambuc// CHECK: 15:1: error: property attributes 'retain' and 'weak' are mutually exclusive 55*f4a2713aSLionel Sambuc// CHECK: @property (weak, retain) void (^aBlockW)(void); 56*f4a2713aSLionel Sambuc// CHECK: ^ 57*f4a2713aSLionel Sambuc// CHECK: 18:1: error: property attributes 'copy' and 'retain' are mutually exclusive 58*f4a2713aSLionel Sambuc// CHECK: @property (copy, retain) void (^aBlockC)(void); 59*f4a2713aSLionel Sambuc// CHECK: ^ 60*f4a2713aSLionel Sambuc// CHECK: 19:1: error: property attributes 'assign' and 'retain' are mutually exclusive 61*f4a2713aSLionel Sambuc// CHECK: @property (assign, retain) void (^aBlockA)(void); 62*f4a2713aSLionel Sambuc// CHECK: ^ 63*f4a2713aSLionel Sambuc// CHECK: 1 warning and 3 errors generated. 64