1*67e74705SXin Li// RUN: %clang_cc1 -fobjc-runtime-has-weak -fobjc-weak -fsyntax-only -verify %s 2*67e74705SXin Li 3*67e74705SXin Li__attribute__((objc_root_class)) 4*67e74705SXin Li@interface A 5*67e74705SXin Li@property (weak) id wa; // expected-note {{property declared here}} 6*67e74705SXin Li@property (weak) id wb; 7*67e74705SXin Li@property (weak) id wc; // expected-note {{property declared here}} 8*67e74705SXin Li@property (weak) id wd; 9*67e74705SXin Li@property (unsafe_unretained) id ua; 10*67e74705SXin Li@property (unsafe_unretained) id ub; // expected-note {{property declared here}} 11*67e74705SXin Li@property (unsafe_unretained) id uc; 12*67e74705SXin Li@property (unsafe_unretained) id ud; 13*67e74705SXin Li@property (strong) id sa; 14*67e74705SXin Li@property (strong) id sb; // expected-note {{property declared here}} 15*67e74705SXin Li@property (strong) id sc; 16*67e74705SXin Li@property (strong) id sd; 17*67e74705SXin Li@end 18*67e74705SXin Li 19*67e74705SXin Li@implementation A { 20*67e74705SXin Li id _wa; // expected-error {{existing instance variable '_wa' for __weak property 'wa' must be __weak}} 21*67e74705SXin Li __weak id _wb; 22*67e74705SXin Li __unsafe_unretained id _wc; // expected-error {{existing instance variable '_wc' for __weak property 'wc' must be __weak}} 23*67e74705SXin Li id _ua; 24*67e74705SXin Li __weak id _ub; // expected-error {{existing instance variable '_ub' for property 'ub' with unsafe_unretained attribute must be __unsafe_unretained}} 25*67e74705SXin Li __unsafe_unretained id _uc; 26*67e74705SXin Li id _sa; 27*67e74705SXin Li __weak id _sb; // expected-error {{existing instance variable '_sb' for strong property 'sb' may not be __weak}} 28*67e74705SXin Li __unsafe_unretained id _sc; 29*67e74705SXin Li} 30*67e74705SXin Li@synthesize wa = _wa; // expected-note {{property synthesized here}} 31*67e74705SXin Li@synthesize wb = _wb; 32*67e74705SXin Li@synthesize wc = _wc; // expected-note {{property synthesized here}} 33*67e74705SXin Li@synthesize wd = _wd; 34*67e74705SXin Li@synthesize ua = _ua; 35*67e74705SXin Li@synthesize ub = _ub; // expected-note {{property synthesized here}} 36*67e74705SXin Li@synthesize uc = _uc; 37*67e74705SXin Li@synthesize ud = _ud; 38*67e74705SXin Li@synthesize sa = _sa; 39*67e74705SXin Li@synthesize sb = _sb; // expected-note {{property synthesized here}} 40*67e74705SXin Li@synthesize sc = _sc; 41*67e74705SXin Li@synthesize sd = _sd; 42*67e74705SXin Li@end 43*67e74705SXin Li 44*67e74705SXin Livoid test_goto() { 45*67e74705SXin Li goto after; // expected-error {{cannot jump from this goto statement to its label}} 46*67e74705SXin Li __weak id x; // expected-note {{jump bypasses initialization of __weak variable}}} 47*67e74705SXin Liafter: 48*67e74705SXin Li return; 49*67e74705SXin Li} 50*67e74705SXin Li 51*67e74705SXin Livoid test_weak_cast(id *value) { 52*67e74705SXin Li __weak id *a = (__weak id*) value; 53*67e74705SXin Li id *b = (__weak id*) value; // expected-error {{initializing 'id *' with an expression of type '__weak id *' changes retain/release properties of pointer}} 54*67e74705SXin Li __weak id *c = (id*) value; // expected-error {{initializing '__weak id *' with an expression of type 'id *' changes retain/release properties of pointer}} 55*67e74705SXin Li} 56*67e74705SXin Li 57*67e74705SXin Livoid test_unsafe_unretained_cast(id *value) { 58*67e74705SXin Li __unsafe_unretained id *a = (__unsafe_unretained id*) value; 59*67e74705SXin Li id *b = (__unsafe_unretained id*) value; 60*67e74705SXin Li __unsafe_unretained id *c = (id*) value; 61*67e74705SXin Li} 62*67e74705SXin Li 63*67e74705SXin Livoid test_cast_qualifier_inference(__weak id *value) { 64*67e74705SXin Li __weak id *a = (id*) value; 65*67e74705SXin Li __unsafe_unretained id *b = (id*) value; // expected-error {{initializing 'id *' with an expression of type '__weak id *' changes retain/release properties of pointer}} 66*67e74705SXin Li} 67*67e74705SXin Li 68