Merge from mainline (165734:167278).
[official-gcc/graphite-test-results.git] / gcc / testsuite / obj-c++.dg / property / synthesize-8.mm
blob071f6f2ad2a048c8c17b10309475978f4742f424
1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
2 /* { dg-do compile } */
4 /* Test that when using @synthesize the instance variable and the
5    property have exactly the same type.  */
7 #include <objc/objc.h>
9 @protocol MyProtocol
10 - (void)aMethod;
11 @end
13 @interface ClassA
14 @end
16 @interface ClassB : ClassA
17 @end
20 /* This is all OK.  */
21 @interface Test
23   int v;
24   float w;
25   id x;
26   Test *y;
27   id <MyProtocol> *z;
28   ClassA *a;
29   ClassB *b;
30   ClassA <MyProtocol> *c;
32 @property (assign) int v;
33 @property (assign) float w;
34 @property (assign) id x;
35 @property (assign) Test *y;
36 @property (assign) id <MyProtocol> *z;
37 @property (assign) ClassA *a;
38 @property (assign) ClassB *b;
39 @end
41 @implementation Test
42 @synthesize v;
43 @synthesize w;
44 @synthesize x;
45 @synthesize y;
46 @synthesize z;
47 @synthesize a;
48 @synthesize b;
49 @end
52 /* This is not OK.  */
53 @interface Test2
55   int v;                   /* { dg-warning "originally specified here" } */
56   float w;                 /* { dg-warning "originally specified here" } */
57   id x;                    /* { dg-warning "originally specified here" } */
58   Test *y;                 /* { dg-warning "originally specified here" } */
59   id <MyProtocol> *z;      /* { dg-warning "originally specified here" } */
60   ClassA *a;               /* { dg-warning "originally specified here" } */
61   ClassB *b;               /* { dg-warning "originally specified here" } */
63 @property (assign) float v;
64 @property (assign) id w;
65 @property (assign) int x;
66 @property (assign) id y;
67 @property (assign) Test *z;
68 @property (assign) ClassB *a;
69 @property (assign) ClassA *b;
70 @end
72 @implementation Test2
73 @synthesize v; /* { dg-error "property .v. is using instance variable .v. of incompatible type" } */
74 @synthesize w; /* { dg-error "property .w. is using instance variable .w. of incompatible type" } */
75 @synthesize x; /* { dg-error "property .x. is using instance variable .x. of incompatible type" } */
76 @synthesize y; /* { dg-error "property .y. is using instance variable .y. of incompatible type" } */
77 @synthesize z; /* { dg-error "property .z. is using instance variable .z. of incompatible type" } */
78 @synthesize a; /* { dg-error "property .a. is using instance variable .a. of incompatible type" } */
79 @synthesize b; /* { dg-error "property .b. is using instance variable .b. of incompatible type" } */
80 @end