blob: 0c1885871045f3a209628069f72e86d4d8cc4914 [file] [log] [blame]
Douglas Gregor85f3f952015-07-07 03:57:15 +00001// 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 Gregor1ac1b632015-07-07 03:58:54 +000015@interface PC1<__covariant T, U : NSObject *> : NSObject
Douglas Gregor85f3f952015-07-07 03:57:15 +000016// expected-note@-2{{type parameter 'U' declared here}}
17@end
18
Douglas Gregor1ac1b632015-07-07 03:58:54 +000019@interface PC1<__covariant T, U : NSObject *> (Cat1)
Douglas Gregor85f3f952015-07-07 03:57:15 +000020@end
21
Douglas Gregore9d95f12015-07-07 03:57:35 +000022typedef PC1<id, NSObject *> PC1Specialization1;
23
Douglas Gregore83b9562015-07-07 03:57:53 +000024typedef PC1Specialization1 <NSObject> PC1Specialization2;
Douglas Gregor85f3f952015-07-07 03:57:15 +000025#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 Gregore83b9562015-07-07 03:57:53 +000033typedef PC1Specialization1<id, NSObject *> PC1Specialization3; // expected-error{{type arguments cannot be applied to already-specialized class type 'PC1Specialization1' (aka 'PC1<id,NSObject *>')}}
34
35typedef PC1Specialization2<id, NSObject *> PC1Specialization4; // expected-error{{already-specialized class type 'PC1Specialization2' (aka 'PC1Specialization1<NSObject>')}}
Douglas Gregore9d95f12015-07-07 03:57:35 +000036
Douglas Gregor1ac1b632015-07-07 03:58:54 +000037@interface NSString : NSObject
38@end
39
40void testCovariance(PC1<NSObject *, NSObject *> *pc1a,
41 PC1<NSString *, NSObject *> *pc1b) {
42 pc1a = pc1b;
43}
44
Douglas Gregor85f3f952015-07-07 03:57:15 +000045#endif