Douglas Gregor | 85f3f95 | 2015-07-07 03:57:15 +0000 | [diff] [blame] | 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 | |
Douglas Gregor | 1ac1b63 | 2015-07-07 03:58:54 +0000 | [diff] [blame] | 15 | @interface PC1<__covariant T, U : NSObject *> : NSObject |
Douglas Gregor | 85f3f95 | 2015-07-07 03:57:15 +0000 | [diff] [blame] | 16 | // expected-note@-2{{type parameter 'U' declared here}} |
| 17 | @end |
| 18 | |
Douglas Gregor | 1ac1b63 | 2015-07-07 03:58:54 +0000 | [diff] [blame] | 19 | @interface PC1<__covariant T, U : NSObject *> (Cat1) |
Douglas Gregor | 85f3f95 | 2015-07-07 03:57:15 +0000 | [diff] [blame] | 20 | @end |
| 21 | |
Douglas Gregor | e9d95f1 | 2015-07-07 03:57:35 +0000 | [diff] [blame] | 22 | typedef PC1<id, NSObject *> PC1Specialization1; |
| 23 | |
Douglas Gregor | e83b956 | 2015-07-07 03:57:53 +0000 | [diff] [blame] | 24 | typedef PC1Specialization1 <NSObject> PC1Specialization2; |
Douglas Gregor | 85f3f95 | 2015-07-07 03:57:15 +0000 | [diff] [blame] | 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 | |
Douglas Gregor | e83b956 | 2015-07-07 03:57:53 +0000 | [diff] [blame] | 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>')}} |
Douglas Gregor | e9d95f1 | 2015-07-07 03:57:35 +0000 | [diff] [blame] | 36 | |
Douglas Gregor | 1ac1b63 | 2015-07-07 03:58:54 +0000 | [diff] [blame] | 37 | @interface NSString : NSObject |
| 38 | @end |
| 39 | |
| 40 | void testCovariance(PC1<NSObject *, NSObject *> *pc1a, |
| 41 | PC1<NSString *, NSObject *> *pc1b) { |
| 42 | pc1a = pc1b; |
| 43 | } |
| 44 | |
Douglas Gregor | 85f3f95 | 2015-07-07 03:57:15 +0000 | [diff] [blame] | 45 | #endif |