| 1 |
// RUN: %clang_cc1 -emit-pch %s -o %t |
| 2 |
// RUN: %clang_cc1 -include-pch %t -verify %s |
| 3 |
|
| 4 |
#ifndef HEADER_INCLUDED |
| 5 |
|
| 6 |
#define HEADER_INCLUDED |
| 7 |
|
| 8 |
@protocol NSObject |
| 9 |
@end |
| 10 |
|
| 11 |
__attribute__((objc_root_class)) |
| 12 |
@interface NSObject |
| 13 |
@end |
| 14 |
|
| 15 |
@interface PC1<__covariant T, U : NSObject *> : NSObject |
| 16 |
// expected-note@-2{{type parameter 'U' declared here}} |
| 17 |
@end |
| 18 |
|
| 19 |
@interface PC1<__covariant T, U : NSObject *> (Cat1) |
| 20 |
@end |
| 21 |
|
| 22 |
typedef PC1<id, NSObject *> PC1Specialization1; |
| 23 |
|
| 24 |
typedef PC1Specialization1 <NSObject> PC1Specialization2; |
| 25 |
#else |
| 26 |
|
| 27 |
@interface PC1<T : NSObject *, // expected-error{{type bound 'NSObject *' for type parameter 'T' conflicts with implicit bound 'id}} |
| 28 |
// expected-note@15{{type parameter 'T' declared here}} |
| 29 |
U : id> (Cat2) // expected-error{{type bound 'id' for type parameter 'U' conflicts with previous bound 'NSObject *'}} |
| 30 |
// expected-note@15{{type parameter 'U' declared here}} |
| 31 |
@end |
| 32 |
|
| 33 |
typedef PC1Specialization1<id, NSObject *> PC1Specialization3; // expected-error{{type arguments cannot be applied to already-specialized class type 'PC1Specialization1' (aka 'PC1<id,NSObject *>')}} |
| 34 |
|
| 35 |
typedef PC1Specialization2<id, NSObject *> PC1Specialization4; // expected-error{{already-specialized class type 'PC1Specialization2' (aka 'PC1Specialization1<NSObject>')}} |
| 36 |
|
| 37 |
@interface NSString : NSObject |
| 38 |
@end |
| 39 |
|
| 40 |
void testCovariance(PC1<NSObject *, NSObject *> *pc1a, |
| 41 |
PC1<NSString *, NSObject *> *pc1b) { |
| 42 |
pc1a = pc1b; |
| 43 |
} |
| 44 |
|
| 45 |
#endif |