1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
2 /* { dg-do compile } */
6 /* Test that if you have a property declared in a class and a
7 sub-class, the types match (unless it's a readonly property, in
8 which case a "specialization" is enough). */
18 @interface MyRootClass
24 @interface MySubClass1 : MyRootClass
27 @interface MySubClass2 : MyRootClass
30 @interface MySubClass3 : MyRootClass <MyProtocolA>
33 @interface MySubClass4 : MySubClass1
38 @interface MyClass : MyRootClass
40 @property (assign) id <MyProtocolA> a; /* { dg-message "originally specified here" } */
41 @property int b; /* { dg-message "originally specified here" } */
42 @property float c; /* { dg-message "originally specified here" } */
43 @property (assign) MyRootClass *d; /* { dg-message "originally specified here" } */
44 @property (assign) MySubClass1 *e; /* { dg-message "originally specified here" } */
45 @property (assign, readonly) MySubClass1 *f; /* { dg-message "originally specified here" } */
46 @property (assign) MySubClass3 *g; /* { dg-message "originally specified here" } */
47 @property (assign, readonly) MySubClass3 *h; /* { dg-message "originally specified here" } */
50 /* The following are all OK because they are identical. */
51 @interface MyClass2 : MyClass
53 @property (assign) id a;
56 @property (assign) MyRootClass *d;
57 @property (assign) MySubClass1 *e;
58 @property (assign, readonly) MySubClass1 *f;
59 @property (assign) MySubClass3 *g;
60 @property (assign, readonly) MySubClass3 *h;
63 /* The following are not OK. */
64 @interface MyClass3 : MyClass
66 @property (assign) MySubClass1 *a; /* { dg-warning "type of property .a. conflicts with previous declaration" } */
67 @property float b; /* { dg-warning "type of property .b. conflicts with previous declaration" } */
68 @property int c; /* { dg-warning "type of property .c. conflicts with previous declaration" } */
69 @property (assign) id d; /* { dg-warning "type of property .d. conflicts with previous declaration" } */
70 @property (assign) MyRootClass *e; /* { dg-warning "type of property .e. conflicts with previous declaration" } */
71 @property (assign, readonly) MyRootClass *f; /* { dg-warning "type of property .f. conflicts with previous declaration" } */
72 @property (assign) MySubClass2 *g; /* { dg-warning "type of property .g. conflicts with previous declaration" } */
73 @property (assign, readonly) MySubClass2 *h; /* { dg-warning "type of property .h. conflicts with previous declaration" } */
76 /* The following are OK. */
77 @interface MyClass4 : MyClass
79 @property (assign, readonly) MySubClass4 *f;
80 @property (assign, readonly) MySubClass3 <MyProtocolB> *h;