1 // RUN: not %clang_cc1 -fsyntax-only -fblocks -fobjc-arc -Wno-objc-root-class %s 2>&1 | FileCheck --check-prefix=CHECK-ARC %s
2 // RUN: not %clang_cc1 -fsyntax-only -fblocks -Wno-objc-root-class %s 2>&1 | FileCheck %s
4 extern void doSomething(void);
11 @property (retain) void (^aBlock)(void);
12 @property (weak, retain) void (^aBlockW)(void);
13 @property (strong, retain) void (^aBlockS)(void); // OK
14 @property (readonly, retain) void (^aBlockR)(void); // OK
15 @property (copy, retain) void (^aBlockC)(void);
16 @property (assign, retain) void (^aBlockA)(void);
21 @dynamic aBlockW, aBlockS, aBlockR, aBlockC, aBlockA;
26 t.aBlock = ^{ doSomething(); };
27 t.aBlockW = ^{ doSomething(); };
28 t.aBlockS = ^{ doSomething(); };
31 // CHECK-ARC: 11:1: warning: retain'ed block property does not copy the block - use copy attribute instead
32 // CHECK-ARC: @property (retain) void (^aBlock)(void);
34 // CHECK-ARC: 12:1: error: property attributes 'retain' and 'weak' are mutually exclusive
35 // CHECK-ARC: @property (weak, retain) void (^aBlockW)(void);
37 // CHECK-ARC: 15:1: error: property attributes 'copy' and 'retain' are mutually exclusive
38 // CHECK-ARC: @property (copy, retain) void (^aBlockC)(void);
40 // CHECK-ARC: 16:1: error: property attributes 'assign' and 'retain' are mutually exclusive
41 // CHECK-ARC: @property (assign, retain) void (^aBlockA)(void);
43 // CHECK-ARC: 27:13: warning: assigning block literal to a weak property; object will be released after assignment
44 // CHECK-ARC: t.aBlockW = ^{ doSomething(); };
45 // CHECK-ARC: ^ ~~~~~~~~~~~~~~~~~~~
46 // CHECK-ARC: 2 warnings and 3 errors generated.
48 // CHECK: 11:1: warning: retain'ed block property does not copy the block - use copy attribute instead
49 // CHECK: @property (retain) void (^aBlock)(void);
51 // CHECK: 12:1: error: property attributes 'retain' and 'weak' are mutually exclusive
52 // CHECK: @property (weak, retain) void (^aBlockW)(void);
54 // CHECK: 15:1: error: property attributes 'copy' and 'retain' are mutually exclusive
55 // CHECK: @property (copy, retain) void (^aBlockC)(void);
57 // CHECK: 16:1: error: property attributes 'assign' and 'retain' are mutually exclusive
58 // CHECK: @property (assign, retain) void (^aBlockA)(void);
60 // CHECK: 1 warning and 3 errors generated.