1*67e74705SXin Li// RUN: %clang_cc1 -fblocks -fobjc-arc -fobjc-runtime-has-weak %s -verify 2*67e74705SXin Li 3*67e74705SXin Li// rdar://21612439 4*67e74705SXin Li 5*67e74705SXin Li__attribute__((objc_root_class)) 6*67e74705SXin Li@interface NSObject 7*67e74705SXin Li@end 8*67e74705SXin Li 9*67e74705SXin Li@class Forward; 10*67e74705SXin Li@class Forward2; 11*67e74705SXin Li 12*67e74705SXin Li// Tests for generic arguments. 13*67e74705SXin Li 14*67e74705SXin Li@interface PC1<T> : NSObject 15*67e74705SXin Li- (T) get; 16*67e74705SXin Li- (void) set: (T) v; 17*67e74705SXin Li@end 18*67e74705SXin Li 19*67e74705SXin Livoid test1a(PC1<__weak id> *obj) { // expected-error {{type argument '__weak id' cannot be qualified with '__weak'}} 20*67e74705SXin Li id x = [obj get]; 21*67e74705SXin Li [obj set: x]; 22*67e74705SXin Li} 23*67e74705SXin Li 24*67e74705SXin Livoid test1b(PC1<__strong id> *obj) { // expected-error {{type argument '__strong id' cannot be qualified with '__strong'}} 25*67e74705SXin Li id x = [obj get]; 26*67e74705SXin Li [obj set: x]; 27*67e74705SXin Li} 28*67e74705SXin Li 29*67e74705SXin Livoid test1c(PC1<id> *obj) { 30*67e74705SXin Li id x = [obj get]; 31*67e74705SXin Li [obj set: x]; 32*67e74705SXin Li} 33*67e74705SXin Li 34*67e74705SXin Li// Test that this doesn't completely kill downstream type-checking. 35*67e74705SXin Livoid test1d(PC1<__weak Forward*> *obj) { // expected-error {{type argument 'Forward *__weak' cannot be qualified with '__weak'}} 36*67e74705SXin Li Forward2 *x = [obj get]; // expected-error {{cannot initialize}} 37*67e74705SXin Li [obj set: x]; 38*67e74705SXin Li} 39*67e74705SXin Li 40*67e74705SXin Livoid test1e(PC1<__strong Forward*> *obj) { // expected-error {{type argument 'Forward *__strong' cannot be qualified with '__strong'}} 41*67e74705SXin Li Forward2 *x = [obj get]; // expected-error {{cannot initialize}} 42*67e74705SXin Li [obj set: x]; 43*67e74705SXin Li} 44*67e74705SXin Li 45*67e74705SXin Livoid test1f(PC1<Forward*> *obj) { 46*67e74705SXin Li Forward2 *x = [obj get]; // expected-error {{cannot initialize}} 47*67e74705SXin Li [obj set: x]; 48*67e74705SXin Li} 49*67e74705SXin Li 50*67e74705SXin Li// Typedefs are fine, just silently ignore them. 51*67e74705SXin Litypedef __strong id StrongID; 52*67e74705SXin Livoid test1g(PC1<StrongID> *obj) { 53*67e74705SXin Li Forward2 *x = [obj get]; 54*67e74705SXin Li [obj set: x]; 55*67e74705SXin Li} 56*67e74705SXin Li 57*67e74705SXin Litypedef __strong Forward *StrongForward; 58*67e74705SXin Livoid test1h(PC1<StrongForward> *obj) { 59*67e74705SXin Li Forward2 *x = [obj get]; // expected-error {{cannot initialize}} 60*67e74705SXin Li [obj set: x]; 61*67e74705SXin Li} 62*67e74705SXin Li 63*67e74705SXin Li// These aren't really ARC-specific, but they're the same basic idea. 64*67e74705SXin Livoid test1i(PC1<const id> *obj) { // expected-error {{type argument 'const id' cannot be qualified with 'const'}} 65*67e74705SXin Li id x = [obj get]; 66*67e74705SXin Li [obj set: x]; 67*67e74705SXin Li} 68*67e74705SXin Li 69*67e74705SXin Livoid test1j(PC1<volatile id> *obj) { // expected-error {{type argument 'volatile id' cannot be qualified with 'volatile'}} 70*67e74705SXin Li id x = [obj get]; 71*67e74705SXin Li [obj set: x]; 72*67e74705SXin Li} 73*67e74705SXin Li 74*67e74705SXin Livoid test1k(PC1<__attribute__((address_space(256))) id> *obj) { // expected-error {{type argument '__attribute__((address_space(256))) id' cannot be qualified with '__attribute__((address_space(256)))'}} 75*67e74705SXin Li id x = [obj get]; 76*67e74705SXin Li [obj set: x]; 77*67e74705SXin Li} 78*67e74705SXin Li 79*67e74705SXin Li// Template-specific tests. 80*67e74705SXin Litemplate <class T> PC1<T> *test2_temp(); 81*67e74705SXin Livoid test2a() { test2_temp<id>(); } 82*67e74705SXin Livoid test2b() { test2_temp<const id>(); } 83*67e74705SXin Livoid test2c() { test2_temp<volatile id>(); } 84*67e74705SXin Livoid test2d() { test2_temp<__strong id>(); } 85*67e74705SXin Livoid test2e() { test2_temp<__weak id>(); } 86*67e74705SXin Livoid test2f() { test2_temp<__attribute__((address_space(256))) id>(); } 87*67e74705SXin Li 88*67e74705SXin Litemplate <class T> PC1<const T> *test3a(); // expected-error {{type argument 'const T' cannot be qualified with 'const'}} 89*67e74705SXin Litemplate <class T> PC1<__strong T> *test3b(); // expected-error {{type argument '__strong T' cannot be qualified with '__strong'}} 90*67e74705SXin Li 91*67e74705SXin Li// Tests for generic parameter bounds. 92*67e74705SXin Li 93*67e74705SXin Li@interface PC2<T : __strong id> // expected-error {{type bound '__strong id' for type parameter 'T' cannot be qualified with '__strong'}} 94*67e74705SXin Li@end 95*67e74705SXin Li 96*67e74705SXin Li@interface PC3<T : __weak id> // expected-error {{type bound '__weak id' for type parameter 'T' cannot be qualified with '__weak'}} 97*67e74705SXin Li@end 98*67e74705SXin Li 99*67e74705SXin Li@interface PC4<T : __strong Forward*> // expected-error {{type bound 'Forward *__strong' for type parameter 'T' cannot be qualified with '__strong'}} 100*67e74705SXin Li@end 101*67e74705SXin Li 102*67e74705SXin Li@interface PC5<T : __weak Forward*> // expected-error {{type bound 'Forward *__weak' for type parameter 'T' cannot be qualified with '__weak'}} 103*67e74705SXin Li@end 104*67e74705SXin Li 105*67e74705SXin Li@interface PC6<T : StrongID> // expected-error {{type bound 'StrongID' (aka '__strong id') for type parameter 'T' cannot be qualified with '__strong'}} 106*67e74705SXin Li@end 107*67e74705SXin Li 108*67e74705SXin Li@interface PC7<T : StrongForward> // expected-error {{type bound 'StrongForward' (aka 'Forward *__strong') for type parameter 'T' cannot be qualified with '__strong'}} 109*67e74705SXin Li@end 110*67e74705SXin Li 111*67e74705SXin Li// These aren't really ARC-specific, but they're the same basic idea. 112*67e74705SXin Li@interface PC8<T : const id> // expected-error {{type bound 'const id' for type parameter 'T' cannot be qualified with 'const'}} 113*67e74705SXin Li@end 114*67e74705SXin Li 115*67e74705SXin Li@interface PC9<T : volatile id> // expected-error {{type bound 'volatile id' for type parameter 'T' cannot be qualified with 'volatile'}} 116*67e74705SXin Li@end 117*67e74705SXin Li 118*67e74705SXin Li@interface PC10<T : __attribute__((address_space(256))) id> // expected-error {{type bound '__attribute__((address_space(256))) id' for type parameter 'T' cannot be qualified with '__attribute__((address_space(256)))'}} 119*67e74705SXin Li@end 120