Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -fsyntax-only -verify |
Fariborz Jahanian | 8beb6a2 | 2011-07-13 17:55:01 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -x objective-c++ %s -fsyntax-only -verify |
Steve Naroff | 15edf0d | 2009-03-03 15:43:24 +0000 | [diff] [blame] | 3 | |
Fariborz Jahanian | 8beb6a2 | 2011-07-13 17:55:01 +0000 | [diff] [blame] | 4 | // rdar://6497242 Inherited overridden protocol declared objects don't work |
| 5 | // rdar://9740328 Case for c++ |
Steve Naroff | 15edf0d | 2009-03-03 15:43:24 +0000 | [diff] [blame] | 6 | |
| 7 | @protocol NSObject @end |
| 8 | @interface NSObject @end |
| 9 | |
| 10 | @protocol FooDelegate<NSObject> |
| 11 | @optional |
| 12 | - (void)fooTask; |
| 13 | @end |
| 14 | |
| 15 | @protocol BarDelegate<NSObject, FooDelegate> |
| 16 | @optional |
| 17 | - (void)barTask; |
| 18 | @end |
| 19 | |
| 20 | @interface Foo : NSObject { |
| 21 | id _delegate; |
| 22 | } |
| 23 | @property(nonatomic, assign) id<FooDelegate> delegate; |
Fariborz Jahanian | 13546a8 | 2011-10-12 00:00:57 +0000 | [diff] [blame] | 24 | @property(nonatomic, assign) id<BarDelegate> delegate2; // expected-note {{property declared here}} |
Steve Naroff | 15edf0d | 2009-03-03 15:43:24 +0000 | [diff] [blame] | 25 | @end |
| 26 | @interface Bar : Foo { |
| 27 | } |
| 28 | @property(nonatomic, assign) id<BarDelegate> delegate; |
| 29 | @property(nonatomic, assign) id<FooDelegate> delegate2; // expected-warning{{property type 'id<FooDelegate>' is incompatible with type 'id<BarDelegate>' inherited from 'Foo'}} |
| 30 | @end |
| 31 | |
| 32 | @interface NSData @end |
| 33 | |
| 34 | @interface NSMutableData : NSData @end |
| 35 | |
| 36 | @interface Base : NSData |
| 37 | @property(assign) id ref; |
| 38 | @property(assign) Base *p_base; |
Fariborz Jahanian | 13546a8 | 2011-10-12 00:00:57 +0000 | [diff] [blame] | 39 | @property(assign) NSMutableData *p_data; // expected-note {{property declared here}} |
Steve Naroff | 15edf0d | 2009-03-03 15:43:24 +0000 | [diff] [blame] | 40 | @end |
| 41 | |
| 42 | @interface Data : Base |
| 43 | @property(assign) NSData *ref; |
| 44 | @property(assign) Data *p_base; |
| 45 | @property(assign) NSData *p_data; // expected-warning{{property type 'NSData *' is incompatible with type 'NSMutableData *' inherited from 'Base'}} |
| 46 | @end |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 47 | |
| 48 | // rdar://15967517 |
| 49 | @protocol P1 |
| 50 | @property (nonatomic) void* selected; |
| 51 | @end |
| 52 | |
| 53 | @protocol P2 |
| 54 | @property (nonatomic) void* selected; // expected-note {{property declared here}} |
| 55 | @end |
| 56 | |
| 57 | @interface MKAnnotationView <P1> |
| 58 | @property (nonatomic) void* selected; // expected-note {{property declared here}} |
| 59 | @property (nonatomic) char selected2; |
| 60 | @end |
| 61 | |
| 62 | @interface Parent : MKAnnotationView <P2> |
| 63 | @property (nonatomic) void* selected1; // expected-note {{property declared here}} |
| 64 | @property (nonatomic) char selected2; |
| 65 | @end |
| 66 | |
| 67 | @interface Child : Parent |
| 68 | @property (nonatomic) char selected; // expected-warning {{property type 'char' is incompatible with type 'void *' inherited from 'MKAnnotationView'}} \ |
| 69 | // expected-warning {{property type 'char' is incompatible with type 'void *' inherited from 'P2'}} |
| 70 | @property (nonatomic) char selected1; // expected-warning {{property type 'char' is incompatible with type 'void *' inherited from 'Parent'}} |
| 71 | @property (nonatomic) char selected2; |
| 72 | @end |