| 1 |
// RUN: %clang_cc1 -fblocks -fobjc-arc -fobjc-runtime-has-weak %s -verify |
| 2 |
|
| 3 |
__attribute__((objc_root_class)) |
| 4 |
@interface NSObject |
| 5 |
@end |
| 6 |
|
| 7 |
@class Forward; |
| 8 |
@class Forward2; |
| 9 |
|
| 10 |
// Tests for generic arguments. |
| 11 |
|
| 12 |
@interface PC1<T> : NSObject |
| 13 |
- (T) get; |
| 14 |
- (void) set: (T) v; // expected-note 4 {{parameter}} |
| 15 |
@end |
| 16 |
|
| 17 |
void test1a(PC1<__weak id> *obj) { // expected-error {{type argument '__weak id' cannot be qualified with '__weak'}} |
| 18 |
id x = [obj get]; |
| 19 |
[obj set: x]; |
| 20 |
} |
| 21 |
|
| 22 |
void test1b(PC1<__strong id> *obj) { // expected-error {{type argument '__strong id' cannot be qualified with '__strong'}} |
| 23 |
id x = [obj get]; |
| 24 |
[obj set: x]; |
| 25 |
} |
| 26 |
|
| 27 |
void test1c(PC1<id> *obj) { |
| 28 |
id x = [obj get]; |
| 29 |
[obj set: x]; |
| 30 |
} |
| 31 |
|
| 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 {{incompatible}} |
| 35 |
[obj set: x]; // expected-error {{incompatible}} |
| 36 |
} |
| 37 |
|
| 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 {{incompatible}} |
| 40 |
[obj set: x]; // expected-error {{incompatible}} |
| 41 |
} |
| 42 |
|
| 43 |
void test1f(PC1<Forward*> *obj) { |
| 44 |
Forward2 *x = [obj get]; // expected-error {{incompatible}} |
| 45 |
[obj set: x]; // expected-error {{incompatible}} |
| 46 |
} |
| 47 |
|
| 48 |
// Typedefs are fine, just silently ignore them. |
| 49 |
typedef __strong id StrongID; |
| 50 |
void test1g(PC1<StrongID> *obj) { |
| 51 |
Forward2 *x = [obj get]; |
| 52 |
[obj set: x]; |
| 53 |
} |
| 54 |
|
| 55 |
typedef __strong Forward *StrongForward; |
| 56 |
void test1h(PC1<StrongForward> *obj) { |
| 57 |
Forward2 *x = [obj get]; // expected-error {{incompatible}} |
| 58 |
[obj set: x]; // expected-error {{incompatible}} |
| 59 |
} |
| 60 |
|
| 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'}} |
| 63 |
id x = [obj get]; |
| 64 |
[obj set: x]; |
| 65 |
} |
| 66 |
|
| 67 |
void test1j(PC1<volatile id> *obj) { // expected-error {{type argument 'volatile id' cannot be qualified with 'volatile'}} |
| 68 |
id x = [obj get]; |
| 69 |
[obj set: x]; |
| 70 |
} |
| 71 |
|
| 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)))'}} |
| 73 |
id x = [obj get]; |
| 74 |
[obj set: x]; |
| 75 |
} |
| 76 |
|
| 77 |
// Tests for generic parameter bounds. |
| 78 |
|
| 79 |
@interface PC2<T : __strong id> // expected-error {{type bound '__strong id' for type parameter 'T' cannot be qualified with '__strong'}} |
| 80 |
@end |
| 81 |
|
| 82 |
@interface PC3<T : __weak id> // expected-error {{type bound '__weak id' for type parameter 'T' cannot be qualified with '__weak'}} |
| 83 |
@end |
| 84 |
|
| 85 |
@interface PC4<T : __strong Forward*> // expected-error {{type bound 'Forward *__strong' for type parameter 'T' cannot be qualified with '__strong'}} |
| 86 |
@end |
| 87 |
|
| 88 |
@interface PC5<T : __weak Forward*> // expected-error {{type bound 'Forward *__weak' for type parameter 'T' cannot be qualified with '__weak'}} |
| 89 |
@end |
| 90 |
|
| 91 |
@interface PC6<T : StrongID> // expected-error {{type bound 'StrongID' (aka '__strong id') for type parameter 'T' cannot be qualified with '__strong'}} |
| 92 |
@end |
| 93 |
|
| 94 |
@interface PC7<T : StrongForward> // expected-error {{type bound 'StrongForward' (aka 'Forward *__strong') for type parameter 'T' cannot be qualified with '__strong'}} |
| 95 |
@end |
| 96 |
|
| 97 |
// These aren't really ARC-specific, but they're the same basic idea. |
| 98 |
@interface PC8<T : const id> // expected-error {{type bound 'const id' for type parameter 'T' cannot be qualified with 'const'}} |
| 99 |
@end |
| 100 |
|
| 101 |
@interface PC9<T : volatile id> // expected-error {{type bound 'volatile id' for type parameter 'T' cannot be qualified with 'volatile'}} |
| 102 |
@end |
| 103 |
|
| 104 |
@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)))'}} |
| 105 |
@end |