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