1 // RUN: not %clang_cc1 -fsyntax-only -fblocks -fobjc-arc -Wno-objc-root-class %s 2>&1 | FileCheck --check-prefix=CHECK-ARC %s
4 // RUN: not %clang_cc1 -fsyntax-only -fblocks -Wno-objc-root-class %s 2>&1 | FileCheck %s
7 extern void doSomething(void);
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);
24 @dynamic aBlockW, aBlockS, aBlockR, aBlockC, aBlockA;
29 t.aBlock = ^{ doSomething(); };
30 t.aBlockW = ^{ doSomething(); };
31 t.aBlockS = ^{ doSomething(); };
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);
37 // CHECK-ARC: 15:1: error: property attributes 'retain' and 'weak' are mutually exclusive
38 // CHECK-ARC: @property (weak, retain) void (^aBlockW)(void);
40 // CHECK-ARC: 18:1: error: property attributes 'copy' and 'retain' are mutually exclusive
41 // CHECK-ARC: @property (copy, retain) void (^aBlockC)(void);
43 // CHECK-ARC: 19:1: error: property attributes 'assign' and 'retain' are mutually exclusive
44 // CHECK-ARC: @property (assign, retain) void (^aBlockA)(void);
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.
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);
54 // CHECK: 15:1: error: property attributes 'retain' and 'weak' are mutually exclusive
55 // CHECK: @property (weak, retain) void (^aBlockW)(void);
57 // CHECK: 18:1: error: property attributes 'copy' and 'retain' are mutually exclusive
58 // CHECK: @property (copy, retain) void (^aBlockC)(void);
60 // CHECK: 19:1: error: property attributes 'assign' and 'retain' are mutually exclusive
61 // CHECK: @property (assign, retain) void (^aBlockA)(void);
63 // CHECK: 1 warning and 3 errors generated.