[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaObjC / protocol-lookup.m
blob26718ae2eaa109b4c42b1d43f106821de476c6b9
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // expected-no-diagnostics
3 @protocol NSObject
4 - retain;
5 - release;
6 @end
8 @interface NSObject
9 - init;
10 - dealloc;
11 @end
13 @protocol Foo <NSObject>
14 @end
16 @protocol Bar <Foo>
17 @end
19 @interface Baz : NSObject {
20         id <Foo> _foo;
21         id <Bar> _bar;
23 - (id)initWithFoo:(id <Foo>)foo bar:(id <Bar>)bar;
24 @end
26 @implementation Baz
28 - (id)init
30         return [self initWithFoo:0 bar:0];
33 - (id)initWithFoo:(id <Foo>)foo bar:(id <Bar>)bar
35         self = [super init];
36         if (self != 0) {
37                 _foo = [foo retain];
38                 _bar = [bar retain];
39         }
40         return self;
43 - dealloc
45         [_foo release];
46         [_bar release];
47         [super dealloc];
48         return 0;
51 @end