blob: e8abf6c1a9b766bb74edda3e0b421b083bf3bbeb [file] [log] [blame]
Daniel Dunbar8fbe78f2009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregor700792c2009-02-05 19:25:20 +00002@protocol NSObject
3- retain;
4- release;
5@end
6
7@interface NSObject
8- init;
9- dealloc;
10@end
11
12@protocol Foo <NSObject>
13@end
14
15@protocol Bar <Foo>
16@end
17
18@interface Baz : NSObject {
19 id <Foo> _foo;
20 id <Bar> _bar;
21}
22- (id)initWithFoo:(id <Foo>)foo bar:(id <Bar>)bar;
23@end
24
25@implementation Baz
26
27- (id)init
28{
29 return [self initWithFoo:0 bar:0];
30}
31
32- (id)initWithFoo:(id <Foo>)foo bar:(id <Bar>)bar
33{
34 self = [super init];
35 if (self != 0) {
36 _foo = [foo retain];
37 _bar = [bar retain];
38 }
39 return self;
40}
41
Fariborz Jahanian07b71652009-05-01 20:07:12 +000042- dealloc
Douglas Gregor700792c2009-02-05 19:25:20 +000043{
44 [_foo release];
45 [_bar release];
46 [super dealloc];
Mike Stump753d1202009-07-22 00:43:08 +000047 return 0;
Douglas Gregor700792c2009-02-05 19:25:20 +000048}
49
50@end
51
Douglas Gregor06e41ae2010-10-21 23:17:00 +000052void rdar8575095(id a) {
53 [id<NSObject>(a) retain];
54 id<NSObject> x(id<NSObject>(0));
Richard Smith943c4402012-07-30 21:30:52 +000055 id<NSObject> x2(id<NSObject>(y)); // expected-warning{{disambiguated as a function declaration}} expected-note{{add a pair of parentheses}}
Douglas Gregor06e41ae2010-10-21 23:17:00 +000056}