Merge from mainline (165734:167278).
[official-gcc/graphite-test-results.git] / gcc / testsuite / obj-c++.dg / property / dotsyntax-15.mm
blob7ddf5300c535e2f2b9c750c8705db4b1edf164b2
1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
2 /* { dg-do compile } */
4 /* Test dot-syntax with accessors to be looked up in protocols.  */
6 #include <stdlib.h>
7 #include <objc/objc.h>
8 #include <objc/runtime.h>
10 @protocol ProtocolA
11 - (int) countA;
12 - (void) setCountA: (int)aNumber;
13 @end
15 @protocol ProtocolB
16 - (int) countB;
17 - (void) setCountB: (int)aNumber;
18 @end
20 @protocol ProtocolC
21 - (int) countC;
22 - (void) setCountC: (int)aNumber;
23 @end
25 @interface MyRootClass
27   Class isa;
29 + (id) initialize;
30 + (id) alloc;
31 - (id) init;
32 @end
34 @interface MySubClass <ProtocolA, ProtocolB, ProtocolC>
35 @end
37 int function (MySubClass *object, int x)
39   object.countA = x;
40   object.countB = x;
41   object.countC = object.countB;
43   return object.countC;
46 int function2 (MyRootClass <ProtocolA, ProtocolB, ProtocolC> *object, int x)
48   object.countA = x;
49   object.countB = x;
50   object.countC = object.countB;
52   return object.countC;
55 int function3 (MyRootClass <ProtocolA, ProtocolB> *object, int x)
57   object.countA = x;
58   object.countB = x;
59   object.countC = object.countB; /* { dg-error "request for member .countC. in" } */
61   return object.countC;          /* { dg-error "request for member .countC. in" } */
64 int function4 (id <ProtocolA, ProtocolB, ProtocolC> object, int x)
66   object.countA = x;
67   object.countB = x;
68   object.countC = object.countB;
70   return object.countC;
73 int function5 (id <ProtocolA, ProtocolB> object, int x)
75   object.countA = x;
76   object.countB = x;
77   object.countC = object.countB; /* { dg-error "request for member .countC. in" } */
79   return object.countC;          /* { dg-error "request for member .countC. in" } */