1// RUN: %clang_cc1 -emit-llvm -triple i686-apple-darwin8 -fobjc-runtime=macosx-fragile-10.5 -o %t %s
2
3// No object generated
4// RUN: not grep OBJC_PROTOCOL_P0 %t
5@protocol P0;
6
7// No object generated
8// RUN: not grep OBJC_PROTOCOL_P1 %t
9@protocol P1 -im1; @end
10
11// Definition triggered by protocol reference.
12// RUN: grep OBJC_PROTOCOL_P2 %t | count 3
13// RUN: grep OBJC_PROTOCOL_INSTANCE_METHODS_P2 %t | count 3
14@protocol P2 -im1; @end
15void f0() { id x = @protocol(P2); }
16
17// Forward definition triggered by protocol reference.
18// RUN: grep OBJC_PROTOCOL_P3 %t | count 3
19// RUN: not grep OBJC_PROTOCOL_INSTANCE_METHODS_P3 %t
20@protocol P3;
21@interface UserP3<P3>
22@end
23@implementation UserP3
24@end
25
26// Definition triggered by class reference.
27// RUN: grep OBJC_PROTOCOL_P4 %t | count 3
28// RUN: grep OBJC_PROTOCOL_INSTANCE_METHODS_P4 %t | count 3
29@protocol P4 -im1; @end
30@interface I0<P4> @end
31@implementation I0 -im1 { return 0; }; @end
32
33// Definition following forward reference.
34// RUN: grep OBJC_PROTOCOL_P5 %t | count 3
35// RUN: grep OBJC_PROTOCOL_INSTANCE_METHODS_P5 %t | count 3
36@protocol P5;
37@interface UserP5<P5> // This generates a forward
38                      // reference, which has to be
39                      // updated on the next line.
40@end
41@protocol P5 -im1; @end
42@implementation UserP5
43
44- im1 { }
45
46@end
47
48// Protocol reference following definition.
49// RUN: grep OBJC_PROTOCOL_P6 %t | count 4
50// RUN: grep OBJC_PROTOCOL_INSTANCE_METHODS_P6 %t | count 3
51@protocol P6 -im1; @end
52@interface I1<P6> @end
53@implementation I1 -im1 { return 0; }; @end
54void f3() { id x = @protocol(P6); }
55
56