Debian Codegraph @

gcc/testsuite/objc.dg/property/dotsyntax-15.m

raw
1 /* Contributed by Nicola Pero <[email protected]>, November 2010. */
2 /* { dg-do compile } */
3
4 /* Test dot-syntax with accessors to be looked up in protocols. */
5
6 #include <stdlib.h>
7 #include <objc/objc.h>
8 #include <objc/runtime.h>
9
10 @protocol ProtocolA
11 - (int) countA;
12 - (void) setCountA: (int)aNumber;
13 @end
14
15 @protocol ProtocolB
16 - (int) countB;
17 - (void) setCountB: (int)aNumber;
18 @end
19
20 @protocol ProtocolC
21 - (int) countC;
22 - (void) setCountC: (int)aNumber;
23 @end
24
25 @interface MyRootClass
26 {
27 Class isa;
28 }
29 + (id) initialize;
30 + (id) alloc;
31 - (id) init;
32 @end
33
34 @interface MySubClass <ProtocolA, ProtocolB, ProtocolC>
35 @end
36
37 int function (MySubClass *object, int x)
38 {
39 object.countA = x;
40 object.countB = x;
41 object.countC = object.countB;
42
43 return object.countC;
44 }
45
46 int function2 (MyRootClass <ProtocolA, ProtocolB, ProtocolC> *object, int x)
47 {
48 object.countA = x;
49 object.countB = x;
50 object.countC = object.countB;
51
52 return object.countC;
53 }
54
55 int function3 (MyRootClass <ProtocolA, ProtocolB> *object, int x)
56 {
57 object.countA = x;
58 object.countB = x;
59 object.countC = object.countB; /* { dg-error "request for member .countC. in something not a structure or union" } */
60
61 return object.countC; /* { dg-error "request for member .countC. in something not a structure or union" } */
62 }
63
64 int function4 (id <ProtocolA, ProtocolB, ProtocolC> object, int x)
65 {
66 object.countA = x;
67 object.countB = x;
68 object.countC = object.countB;
69
70 return object.countC;
71 }
72
73 int function5 (id <ProtocolA, ProtocolB> object, int x)
74 {
75 object.countA = x;
76 object.countB = x;
77 object.countC = object.countB; /* { dg-error "request for member .countC. in something not a structure or union" } */
78
79 return object.countC; /* { dg-error "request for member .countC. in something not a structure or union" } */
80 }