xref: /aosp_15_r20/external/clang/test/SemaObjC/protocol-lookup.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1 -fsyntax-only -verify %s
2*67e74705SXin Li// expected-no-diagnostics
3*67e74705SXin Li@protocol NSObject
4*67e74705SXin Li- retain;
5*67e74705SXin Li- release;
6*67e74705SXin Li@end
7*67e74705SXin Li
8*67e74705SXin Li@interface NSObject
9*67e74705SXin Li- init;
10*67e74705SXin Li- dealloc;
11*67e74705SXin Li@end
12*67e74705SXin Li
13*67e74705SXin Li@protocol Foo <NSObject>
14*67e74705SXin Li@end
15*67e74705SXin Li
16*67e74705SXin Li@protocol Bar <Foo>
17*67e74705SXin Li@end
18*67e74705SXin Li
19*67e74705SXin Li@interface Baz : NSObject {
20*67e74705SXin Li	id <Foo> _foo;
21*67e74705SXin Li	id <Bar> _bar;
22*67e74705SXin Li}
23*67e74705SXin Li- (id)initWithFoo:(id <Foo>)foo bar:(id <Bar>)bar;
24*67e74705SXin Li@end
25*67e74705SXin Li
26*67e74705SXin Li@implementation Baz
27*67e74705SXin Li
28*67e74705SXin Li- (id)init
29*67e74705SXin Li{
30*67e74705SXin Li	return [self initWithFoo:0 bar:0];
31*67e74705SXin Li}
32*67e74705SXin Li
33*67e74705SXin Li- (id)initWithFoo:(id <Foo>)foo bar:(id <Bar>)bar
34*67e74705SXin Li{
35*67e74705SXin Li	self = [super init];
36*67e74705SXin Li	if (self != 0) {
37*67e74705SXin Li		_foo = [foo retain];
38*67e74705SXin Li		_bar = [bar retain];
39*67e74705SXin Li	}
40*67e74705SXin Li	return self;
41*67e74705SXin Li}
42*67e74705SXin Li
43*67e74705SXin Li- dealloc
44*67e74705SXin Li{
45*67e74705SXin Li	[_foo release];
46*67e74705SXin Li	[_bar release];
47*67e74705SXin Li	[super dealloc];
48*67e74705SXin Li	return 0;
49*67e74705SXin Li}
50*67e74705SXin Li
51*67e74705SXin Li@end
52*67e74705SXin Li
53