1 // RUN: %clang_cc1 -fblocks -fobjc-arc -fobjc-runtime-has-weak %s -verify
3 __attribute__((objc_root_class))
10 // Tests for generic arguments.
12 @interface PC1<T> : NSObject
14 - (void) set: (T) v; // expected-note 4{{passing argument to}}
17 void test1a(PC1<__weak id> *obj) { // expected-error {{type argument '__weak id' cannot be qualified with '__weak'}}
22 void test1b(PC1<__strong id> *obj) { // expected-error {{type argument '__strong id' cannot be qualified with '__strong'}}
27 void test1c(PC1<id> *obj) {
32 // Test that this doesn't completely kill downstream type-checking.
33 void test1d(PC1<__weak Forward*> *obj) { // expected-error {{type argument 'Forward *__weak' cannot be qualified with '__weak'}}
34 Forward2 *x = [obj get]; // expected-error {{cannot initialize}}
35 [obj set: x]; // expected-error {{cannot initialize a parameter of type 'Forward *' with an lvalue of type 'Forward2 *__strong'}}
38 void test1e(PC1<__strong Forward*> *obj) { // expected-error {{type argument 'Forward *__strong' cannot be qualified with '__strong'}}
39 Forward2 *x = [obj get]; // expected-error {{cannot initialize}}
40 [obj set: x]; // expected-error {{cannot initialize a parameter of type 'Forward *'}}
43 void test1f(PC1<Forward*> *obj) {
44 Forward2 *x = [obj get]; // expected-error {{cannot initialize}}
45 [obj set: x]; // expected-error {{cannot initialize a parameter of type 'Forward *'}}
48 // Typedefs are fine, just silently ignore them.
49 typedef __strong id StrongID;
50 void test1g(PC1<StrongID> *obj) {
51 Forward2 *x = [obj get];
55 typedef __strong Forward *StrongForward;
56 void test1h(PC1<StrongForward> *obj) {
57 Forward2 *x = [obj get]; // expected-error {{cannot initialize}}
58 [obj set: x]; // expected-error {{cannot initialize a parameter of type 'Forward *'}}
61 // These aren't really ARC-specific, but they're the same basic idea.
62 void test1i(PC1<const id> *obj) { // expected-error {{type argument 'const id' cannot be qualified with 'const'}}
67 void test1j(PC1<volatile id> *obj) { // expected-error {{type argument 'volatile id' cannot be qualified with 'volatile'}}
72 void 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)))'}}
77 // Template-specific tests.
78 template <class T> PC1<T> *test2_temp();
79 void test2a() { test2_temp<id>(); }
80 void test2b() { test2_temp<const id>(); }
81 void test2c() { test2_temp<volatile id>(); }
82 void test2d() { test2_temp<__strong id>(); }
83 void test2e() { test2_temp<__weak id>(); }
84 void test2f() { test2_temp<__attribute__((address_space(256))) id>(); }
86 template <class T> PC1<const T> *test3a(); // expected-error {{type argument 'const T' cannot be qualified with 'const'}}
87 template <class T> PC1<__strong T> *test3b(); // expected-error {{type argument '__strong T' cannot be qualified with '__strong'}}
89 // Tests for generic parameter bounds.
91 @interface PC2<T : __strong id> // expected-error {{type bound '__strong id' for type parameter 'T' cannot be qualified with '__strong'}}
94 @interface PC3<T : __weak id> // expected-error {{type bound '__weak id' for type parameter 'T' cannot be qualified with '__weak'}}
97 @interface PC4<T : __strong Forward*> // expected-error {{type bound 'Forward *__strong' for type parameter 'T' cannot be qualified with '__strong'}}
100 @interface PC5<T : __weak Forward*> // expected-error {{type bound 'Forward *__weak' for type parameter 'T' cannot be qualified with '__weak'}}
103 @interface PC6<T : StrongID> // expected-error {{type bound 'StrongID' (aka '__strong id') for type parameter 'T' cannot be qualified with '__strong'}}
106 @interface PC7<T : StrongForward> // expected-error {{type bound 'StrongForward' (aka 'Forward *__strong') for type parameter 'T' cannot be qualified with '__strong'}}
109 // These aren't really ARC-specific, but they're the same basic idea.
110 @interface PC8<T : const id> // expected-error {{type bound 'const id' for type parameter 'T' cannot be qualified with 'const'}}
113 @interface PC9<T : volatile id> // expected-error {{type bound 'volatile id' for type parameter 'T' cannot be qualified with 'volatile'}}
116 @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)))'}}