xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenObjC/protocols.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -emit-llvm-only %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambucvoid p(const char*, ...);
4*f4a2713aSLionel Sambuc
5*f4a2713aSLionel Sambuc@interface Root
6*f4a2713aSLionel Sambuc+(int) maxValue;
7*f4a2713aSLionel Sambuc-(int) conformsTo: (id) x;
8*f4a2713aSLionel Sambuc@end
9*f4a2713aSLionel Sambuc
10*f4a2713aSLionel Sambuc@protocol P0;
11*f4a2713aSLionel Sambuc
12*f4a2713aSLionel Sambuc@protocol P1
13*f4a2713aSLionel Sambuc+(void) classMethodReq0;
14*f4a2713aSLionel Sambuc-(void) methodReq0;
15*f4a2713aSLionel Sambuc@optional
16*f4a2713aSLionel Sambuc+(void) classMethodOpt1;
17*f4a2713aSLionel Sambuc-(void) methodOpt1;
18*f4a2713aSLionel Sambuc@required
19*f4a2713aSLionel Sambuc+(void) classMethodReq2;
20*f4a2713aSLionel Sambuc-(void) methodReq2;
21*f4a2713aSLionel Sambuc@end
22*f4a2713aSLionel Sambuc
23*f4a2713aSLionel Sambuc@protocol P2
24*f4a2713aSLionel Sambuc//@property(readwrite) int x;
25*f4a2713aSLionel Sambuc@end
26*f4a2713aSLionel Sambuc
27*f4a2713aSLionel Sambuc@protocol P3<P1, P2>
28*f4a2713aSLionel Sambuc-(id <P1>) print0;
29*f4a2713aSLionel Sambuc-(void) print1;
30*f4a2713aSLionel Sambuc@end
31*f4a2713aSLionel Sambuc
32*f4a2713aSLionel Sambucvoid foo(const id a) {
33*f4a2713aSLionel Sambuc  void *p = @protocol(P3);
34*f4a2713aSLionel Sambuc}
35*f4a2713aSLionel Sambuc
36*f4a2713aSLionel Sambucint main() {
37*f4a2713aSLionel Sambuc  Protocol *P0 = @protocol(P0);
38*f4a2713aSLionel Sambuc  Protocol *P1 = @protocol(P1);
39*f4a2713aSLionel Sambuc  Protocol *P2 = @protocol(P2);
40*f4a2713aSLionel Sambuc  Protocol *P3 = @protocol(P3);
41*f4a2713aSLionel Sambuc
42*f4a2713aSLionel Sambuc#define Pbool(X) p(#X ": %s\n", X ? "yes" : "no");
43*f4a2713aSLionel Sambuc  Pbool([P0 conformsTo: P1]);
44*f4a2713aSLionel Sambuc  Pbool([P1 conformsTo: P0]);
45*f4a2713aSLionel Sambuc  Pbool([P1 conformsTo: P2]);
46*f4a2713aSLionel Sambuc  Pbool([P2 conformsTo: P1]);
47*f4a2713aSLionel Sambuc  Pbool([P3 conformsTo: P1]);
48*f4a2713aSLionel Sambuc  Pbool([P1 conformsTo: P3]);
49*f4a2713aSLionel Sambuc
50*f4a2713aSLionel Sambuc  return 0;
51*f4a2713aSLionel Sambuc}
52*f4a2713aSLionel Sambuc
53*f4a2713aSLionel Sambuc// rdar://problem/7992749
54*f4a2713aSLionel Sambuctypedef Root<P1> P1Object;
55*f4a2713aSLionel Sambucint test10() {
56*f4a2713aSLionel Sambuc  return [P1Object maxValue];
57*f4a2713aSLionel Sambuc}
58