1 // RUN: %clang_cc1 -fblocks -fobjc-arc -fobjc-runtime-has-weak %s -verify
5 __attribute__((objc_root_class))
12 // Tests for generic arguments.
14 @interface PC1<T> : NSObject
16 - (void) set: (T) v; // expected-note 4 {{parameter}}
19 void test1a(PC1<__weak id> *obj) { // expected-error {{type argument '__weak id' cannot be qualified with '__weak'}}
24 void test1b(PC1<__strong id> *obj) { // expected-error {{type argument '__strong id' cannot be qualified with '__strong'}}
29 void test1c(PC1<id> *obj) {
34 // Test that this doesn't completely kill downstream type-checking.
35 void test1d(PC1<__weak Forward*> *obj) { // expected-error {{type argument 'Forward *__weak' cannot be qualified with '__weak'}}
36 Forward2 *x = [obj get]; // expected-warning {{incompatible}}
37 [obj set: x]; // expected-warning {{incompatible}}
40 void test1e(PC1<__strong Forward*> *obj) { // expected-error {{type argument 'Forward *__strong' cannot be qualified with '__strong'}}
41 Forward2 *x = [obj get]; // expected-warning {{incompatible}}
42 [obj set: x]; // expected-warning {{incompatible}}
45 void test1f(PC1<Forward*> *obj) {
46 Forward2 *x = [obj get]; // expected-warning {{incompatible}}
47 [obj set: x]; // expected-warning {{incompatible}}
50 // Typedefs are fine, just silently ignore them.
51 typedef __strong id StrongID;
52 void test1g(PC1<StrongID> *obj) {
53 Forward2 *x = [obj get];
57 typedef __strong Forward *StrongForward;
58 void test1h(PC1<StrongForward> *obj) {
59 Forward2 *x = [obj get]; // expected-warning {{incompatible}}
60 [obj set: x]; // expected-warning {{incompatible}}
63 // These aren't really ARC-specific, but they're the same basic idea.
64 void test1i(PC1<const id> *obj) { // expected-error {{type argument 'const id' cannot be qualified with 'const'}}
69 void test1j(PC1<volatile id> *obj) { // expected-error {{type argument 'volatile id' cannot be qualified with 'volatile'}}
74 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)))'}}
79 // Tests for generic parameter bounds.
81 @interface PC2<T : __strong id> // expected-error {{type bound '__strong id' for type parameter 'T' cannot be qualified with '__strong'}}
84 @interface PC3<T : __weak id> // expected-error {{type bound '__weak id' for type parameter 'T' cannot be qualified with '__weak'}}
87 @interface PC4<T : __strong Forward*> // expected-error {{type bound 'Forward *__strong' for type parameter 'T' cannot be qualified with '__strong'}}
90 @interface PC5<T : __weak Forward*> // expected-error {{type bound 'Forward *__weak' for type parameter 'T' cannot be qualified with '__weak'}}
93 @interface PC6<T : StrongID> // expected-error {{type bound 'StrongID' (aka '__strong id') for type parameter 'T' cannot be qualified with '__strong'}}
96 @interface PC7<T : StrongForward> // expected-error {{type bound 'StrongForward' (aka 'Forward *__strong') for type parameter 'T' cannot be qualified with '__strong'}}
99 // These aren't really ARC-specific, but they're the same basic idea.
100 @interface PC8<T : const id> // expected-error {{type bound 'const id' for type parameter 'T' cannot be qualified with 'const'}}
103 @interface PC9<T : volatile id> // expected-error {{type bound 'volatile id' for type parameter 'T' cannot be qualified with 'volatile'}}
106 @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)))'}}