xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/property-inherited.m (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc// RUN: %clang_cc1 %s -fsyntax-only -verify
2f4a2713aSLionel Sambuc// RUN: %clang_cc1 -x objective-c++ %s -fsyntax-only -verify
3f4a2713aSLionel Sambuc
4f4a2713aSLionel Sambuc// rdar://6497242 Inherited overridden protocol declared objects don't work
5f4a2713aSLionel Sambuc// rdar://9740328 Case for c++
6f4a2713aSLionel Sambuc
7f4a2713aSLionel Sambuc@protocol NSObject @end
8f4a2713aSLionel Sambuc@interface NSObject @end
9f4a2713aSLionel Sambuc
10f4a2713aSLionel Sambuc@protocol FooDelegate<NSObject>
11f4a2713aSLionel Sambuc@optional
12f4a2713aSLionel Sambuc- (void)fooTask;
13f4a2713aSLionel Sambuc@end
14f4a2713aSLionel Sambuc
15f4a2713aSLionel Sambuc@protocol BarDelegate<NSObject, FooDelegate>
16f4a2713aSLionel Sambuc@optional
17f4a2713aSLionel Sambuc- (void)barTask;
18f4a2713aSLionel Sambuc@end
19f4a2713aSLionel Sambuc
20f4a2713aSLionel Sambuc@interface Foo : NSObject {
21f4a2713aSLionel Sambuc  id _delegate;
22f4a2713aSLionel Sambuc}
23f4a2713aSLionel Sambuc@property(nonatomic, assign) id<FooDelegate> delegate;
24f4a2713aSLionel Sambuc@property(nonatomic, assign) id<BarDelegate> delegate2; // expected-note {{property declared here}}
25f4a2713aSLionel Sambuc@end
26f4a2713aSLionel Sambuc@interface Bar : Foo {
27f4a2713aSLionel Sambuc}
28f4a2713aSLionel Sambuc@property(nonatomic, assign) id<BarDelegate> delegate;
29f4a2713aSLionel Sambuc@property(nonatomic, assign) id<FooDelegate> delegate2; // expected-warning{{property type 'id<FooDelegate>' is incompatible with type 'id<BarDelegate>' inherited from 'Foo'}}
30f4a2713aSLionel Sambuc@end
31f4a2713aSLionel Sambuc
32f4a2713aSLionel Sambuc@interface NSData @end
33f4a2713aSLionel Sambuc
34f4a2713aSLionel Sambuc@interface NSMutableData : NSData @end
35f4a2713aSLionel Sambuc
36f4a2713aSLionel Sambuc@interface Base : NSData
37f4a2713aSLionel Sambuc@property(assign) id ref;
38f4a2713aSLionel Sambuc@property(assign) Base *p_base;
39f4a2713aSLionel Sambuc@property(assign) NSMutableData *p_data;	 // expected-note {{property declared here}}
40f4a2713aSLionel Sambuc@end
41f4a2713aSLionel Sambuc
42f4a2713aSLionel Sambuc@interface Data : Base
43f4a2713aSLionel Sambuc@property(assign) NSData *ref;
44f4a2713aSLionel Sambuc@property(assign) Data *p_base;
45f4a2713aSLionel Sambuc@property(assign) NSData *p_data;	// expected-warning{{property type 'NSData *' is incompatible with type 'NSMutableData *' inherited from 'Base'}}
46f4a2713aSLionel Sambuc@end
47*0a6a1f1dSLionel Sambuc
48*0a6a1f1dSLionel Sambuc// rdar://15967517
49*0a6a1f1dSLionel Sambuc@protocol P1
50*0a6a1f1dSLionel Sambuc@property (nonatomic) void* selected;
51*0a6a1f1dSLionel Sambuc@end
52*0a6a1f1dSLionel Sambuc
53*0a6a1f1dSLionel Sambuc@protocol P2
54*0a6a1f1dSLionel Sambuc@property (nonatomic) void* selected; // expected-note {{property declared here}}
55*0a6a1f1dSLionel Sambuc@end
56*0a6a1f1dSLionel Sambuc
57*0a6a1f1dSLionel Sambuc@interface MKAnnotationView <P1>
58*0a6a1f1dSLionel Sambuc@property (nonatomic) void* selected; // expected-note {{property declared here}}
59*0a6a1f1dSLionel Sambuc@property (nonatomic) char selected2;
60*0a6a1f1dSLionel Sambuc@end
61*0a6a1f1dSLionel Sambuc
62*0a6a1f1dSLionel Sambuc@interface Parent : MKAnnotationView <P2>
63*0a6a1f1dSLionel Sambuc@property (nonatomic) void* selected1; // expected-note {{property declared here}}
64*0a6a1f1dSLionel Sambuc@property (nonatomic) char selected2;
65*0a6a1f1dSLionel Sambuc@end
66*0a6a1f1dSLionel Sambuc
67*0a6a1f1dSLionel Sambuc@interface Child : Parent
68*0a6a1f1dSLionel Sambuc@property (nonatomic) char selected; // expected-warning {{property type 'char' is incompatible with type 'void *' inherited from 'MKAnnotationView'}} \
69*0a6a1f1dSLionel Sambuc				     // expected-warning {{property type 'char' is incompatible with type 'void *' inherited from 'P2'}}
70*0a6a1f1dSLionel Sambuc@property (nonatomic) char selected1; // expected-warning {{property type 'char' is incompatible with type 'void *' inherited from 'Parent'}}
71*0a6a1f1dSLionel Sambuc@property (nonatomic) char selected2;
72*0a6a1f1dSLionel Sambuc@end
73