1 // RUN: %clang_cc1 -fobjc-runtime-has-weak -fobjc-weak -fsyntax-only -verify %s
3 __attribute__((objc_root_class))
5 @property (weak) id wa; // expected-note {{property declared here}}
6 @property (weak) id wb;
7 @property (weak) id wc; // expected-note {{property declared here}}
8 @property (weak) id wd;
9 @property (unsafe_unretained) id ua;
10 @property (unsafe_unretained) id ub; // expected-note {{property declared here}}
11 @property (unsafe_unretained) id uc;
12 @property (unsafe_unretained) id ud;
13 @property (strong) id sa;
14 @property (strong) id sb; // expected-note {{property declared here}}
15 @property (strong) id sc;
16 @property (strong) id sd;
20 id _wa; // expected-error {{existing instance variable '_wa' for __weak property 'wa' must be __weak}}
22 __unsafe_unretained id _wc; // expected-error {{existing instance variable '_wc' for __weak property 'wc' must be __weak}}
24 __weak id _ub; // expected-error {{existing instance variable '_ub' for property 'ub' with unsafe_unretained attribute must be __unsafe_unretained}}
25 __unsafe_unretained id _uc;
27 __weak id _sb; // expected-error {{existing instance variable '_sb' for strong property 'sb' may not be __weak}}
28 __unsafe_unretained id _sc;
30 @synthesize wa = _wa; // expected-note {{property synthesized here}}
32 @synthesize wc = _wc; // expected-note {{property synthesized here}}
35 @synthesize ub = _ub; // expected-note {{property synthesized here}}
39 @synthesize sb = _sb; // expected-note {{property synthesized here}}
44 void test_goto(void) {
45 goto after; // expected-error {{cannot jump from this goto statement to its label}}
46 __weak id x; // expected-note {{jump bypasses initialization of __weak variable}}}
51 void test_weak_cast(id *value) {
52 __weak id *a = (__weak id*) value;
53 id *b = (__weak id*) value; // expected-error {{initializing 'id *' with an expression of type '__weak id *' changes retain/release properties of pointer}}
54 __weak id *c = (id*) value; // expected-error {{initializing '__weak id *' with an expression of type 'id *' changes retain/release properties of pointer}}
57 void test_unsafe_unretained_cast(id *value) {
58 __unsafe_unretained id *a = (__unsafe_unretained id*) value;
59 id *b = (__unsafe_unretained id*) value;
60 __unsafe_unretained id *c = (id*) value;
63 void test_cast_qualifier_inference(__weak id *value) {
64 __weak id *a = (id*) value;
65 __unsafe_unretained id *b = (id *)value; // expected-error {{initializing 'id *' with an expression of type '__weak id *' changes retain/release properties of pointer}}