Merge from mainline (165734:167278).
[official-gcc/graphite-test-results.git] / gcc / testsuite / objc.dg / property / at-property-20.m
blob1bb49da2b78d7723469f8b9392d85047c5ab370d
1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
2 /* { dg-do compile } */
4 #include <objc/objc.h>
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).  */
10 @protocol MyProtocolA
11 - (void) doNothingA;
12 @end
14 @protocol MyProtocolB
15 - (void) doNothingB;
16 @end
18 @interface MyRootClass
20   Class isa;
22 @end
24 @interface MySubClass1 : MyRootClass
25 @end
27 @interface MySubClass2 : MyRootClass
28 @end
30 @interface MySubClass3 : MyRootClass <MyProtocolA>
31 @end
33 @interface MySubClass4 : MySubClass1
34 @end
36 /* Now, the test.  */
38 @interface MyClass : MyRootClass
39 { }
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" } */
48 @end
50 /* The following are all OK because they are identical.  */
51 @interface MyClass2 : MyClass
52 { }
53 @property (assign) id a;
54 @property int b;
55 @property float c;
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;
61 @end
63 /* The following are not OK.  */
64 @interface MyClass3 : MyClass
65 { }
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" } */
74 @end
76 /* The following are OK.  */
77 @interface MyClass4 : MyClass
78 { }
79 @property (assign, readonly) MySubClass4 *f;
80 @property (assign, readonly) MySubClass3 <MyProtocolB> *h;
81 @end