llvm-project
72 строки · 2.1 Кб
1// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
2
3// CHECK: @"_OBJC_$_PROTOCOL_METHOD_TYPES_P1" = internal global
4// CHECK: @[[PROTO_P1:"_OBJC_PROTOCOL_\$_P1"]] = weak hidden
5// CHECK: @[[LABEL_PROTO_P1:"_OBJC_LABEL_PROTOCOL_\$_P1"]] = weak hidden global ptr @[[PROTO_P1]]
6// CHECK: @[[PROTO_P2:"_OBJC_PROTOCOL_\$_P2"]] = weak hidden
7// CHECK: @[[LABEL_PROTO_P2:"_OBJC_LABEL_PROTOCOL_\$_P2"]] = weak hidden global ptr @[[PROTO_P2]]
8// CHECK: @"_OBJC_$_PROTOCOL_REFS_P3" = internal global { i64, [3 x ptr] } { i64 2, [3 x ptr] [ptr @[[PROTO_P1]], ptr @[[PROTO_P2]], ptr null] }
9// CHECK: @[[PROTO_P3:"_OBJC_PROTOCOL_\$_P3"]] = weak hidden
10// CHECK: @[[LABEL_PROTO_P3:"_OBJC_LABEL_PROTOCOL_\$_P3"]] = weak hidden global ptr @[[PROTO_P3]]
11// CHECK: "_OBJC_PROTOCOL_REFERENCE_$_P3" = weak hidden global ptr @[[PROTO_P3]]
12// CHECK: @[[PROTO_P0:"_OBJC_PROTOCOL_\$_P0"]] = weak hidden
13// CHECK: @[[LABEL_PROTO_P0:"_OBJC_LABEL_PROTOCOL_\$_P0"]] = weak hidden global ptr @[[PROTO_P0]]
14// CHECK: "_OBJC_PROTOCOL_REFERENCE_$_P0" = weak hidden global ptr @[[PROTO_P0]]
15// CHECK: "_OBJC_PROTOCOL_REFERENCE_$_P1" = weak hidden global ptr @[[PROTO_P1]]
16// CHECK: "_OBJC_PROTOCOL_REFERENCE_$_P2" = weak hidden global ptr @[[PROTO_P2]]
17
18void p(const char*, ...);
19
20@interface Root
21+(int) maxValue;
22-(int) conformsTo: (id) x;
23@end
24
25@protocol P0
26@end
27
28@protocol P1
29+(void) classMethodReq0;
30-(void) methodReq0;
31@optional
32+(void) classMethodOpt1;
33-(void) methodOpt1;
34@required
35+(void) classMethodReq2;
36-(void) methodReq2;
37@end
38
39@protocol P2
40//@property(readwrite) int x;
41@end
42
43@protocol P3<P1, P2>
44-(id <P1>) print0;
45-(void) print1;
46@end
47
48void foo(const id a) {
49void *p = @protocol(P3);
50}
51
52int main(void) {
53Protocol *P0 = @protocol(P0);
54Protocol *P1 = @protocol(P1);
55Protocol *P2 = @protocol(P2);
56Protocol *P3 = @protocol(P3);
57
58#define Pbool(X) p(#X ": %s\n", X ? "yes" : "no");
59Pbool([P0 conformsTo: P1]);
60Pbool([P1 conformsTo: P0]);
61Pbool([P1 conformsTo: P2]);
62Pbool([P2 conformsTo: P1]);
63Pbool([P3 conformsTo: P1]);
64Pbool([P1 conformsTo: P3]);
65
66return 0;
67}
68
69typedef Root<P1> P1Object;
70int test10(void) {
71return [P1Object maxValue];
72}
73