blob: 4792fa6644dd909771319f822f3b493674183f8c [file] [log] [blame]
Steve Naroffaa73eec2008-05-31 22:33:45 +00001// RUN: clang -fsyntax-only -verify -pedantic %s
2@protocol NSObject
3@end
4
5@protocol DTOutputStreams <NSObject>
6@end
7
8@interface DTFilterOutputStream <DTOutputStreams>
9- nextOutputStream;
10@end
11
12@implementation DTFilterOutputStream
13- (id)initWithNextOutputStream:(id <DTOutputStreams>) outputStream {
14 id <DTOutputStreams> nextOutputStream = [self nextOutputStream];
15 self = nextOutputStream;
16 return nextOutputStream ? nextOutputStream : self;
17}
18- nextOutputStream {
19 return self;
20}
21@end
Steve Naroff19b87d22008-05-31 23:10:15 +000022
23@interface DTFilterOutputStream2
24- nextOutputStream;
25@end
26
27@implementation DTFilterOutputStream2 // expected-warning {{incomplete implementation}} expected-warning {{method definition for 'nextOutputStream' not found}}
28- (id)initWithNextOutputStream:(id <DTOutputStreams>) outputStream {
29 id <DTOutputStreams> nextOutputStream = [self nextOutputStream];
30 // GCC warns about both of these.
Steve Naroff39579072008-10-14 22:18:38 +000031 self = nextOutputStream; // expected-warning {{incompatible type assigning 'id<DTOutputStreams>', expected 'DTFilterOutputStream2 *'}}
Daniel Dunbar40727a42008-09-03 17:53:25 +000032 return nextOutputStream ? nextOutputStream : self;
Steve Naroff19b87d22008-05-31 23:10:15 +000033}
34@end
35
36// No @interface declaration for DTFilterOutputStream3
37@implementation DTFilterOutputStream3 // expected-warning {{cannot find interface declaration for 'DTFilterOutputStream3'}}
38- (id)initWithNextOutputStream:(id <DTOutputStreams>) outputStream {
Steve Naroff6b9dfd42009-03-04 15:11:40 +000039 id <DTOutputStreams> nextOutputStream = [self nextOutputStream]; // expected-warning {{method '-nextOutputStream' not found (return type defaults to 'id')}}
Steve Naroff19b87d22008-05-31 23:10:15 +000040 // GCC warns about both of these as well (no errors).
Steve Naroff39579072008-10-14 22:18:38 +000041 self = nextOutputStream; // expected-warning {{incompatible type assigning 'id<DTOutputStreams>', expected 'DTFilterOutputStream3 *'}}
Daniel Dunbar40727a42008-09-03 17:53:25 +000042 return nextOutputStream ? nextOutputStream : self;
Steve Naroff19b87d22008-05-31 23:10:15 +000043}
44@end