2009-03-24 05:24:46 +03:00
|
|
|
// RUN: clang-cc -fsyntax-only -verify -pedantic %s
|
2008-06-01 02:33:45 +04:00
|
|
|
@protocol NSObject
|
|
|
|
@end
|
|
|
|
|
|
|
|
@protocol DTOutputStreams <NSObject>
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface DTFilterOutputStream <DTOutputStreams>
|
|
|
|
- nextOutputStream;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation DTFilterOutputStream
|
|
|
|
- (id)initWithNextOutputStream:(id <DTOutputStreams>) outputStream {
|
|
|
|
id <DTOutputStreams> nextOutputStream = [self nextOutputStream];
|
|
|
|
self = nextOutputStream;
|
|
|
|
return nextOutputStream ? nextOutputStream : self;
|
|
|
|
}
|
|
|
|
- nextOutputStream {
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
@end
|
2008-06-01 03:10:15 +04:00
|
|
|
|
|
|
|
@interface DTFilterOutputStream2
|
|
|
|
- nextOutputStream;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation DTFilterOutputStream2 // expected-warning {{incomplete implementation}} expected-warning {{method definition for 'nextOutputStream' not found}}
|
|
|
|
- (id)initWithNextOutputStream:(id <DTOutputStreams>) outputStream {
|
|
|
|
id <DTOutputStreams> nextOutputStream = [self nextOutputStream];
|
|
|
|
// GCC warns about both of these.
|
2008-10-15 02:18:38 +04:00
|
|
|
self = nextOutputStream; // expected-warning {{incompatible type assigning 'id<DTOutputStreams>', expected 'DTFilterOutputStream2 *'}}
|
2008-09-03 21:53:25 +04:00
|
|
|
return nextOutputStream ? nextOutputStream : self;
|
2008-06-01 03:10:15 +04:00
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
// No @interface declaration for DTFilterOutputStream3
|
|
|
|
@implementation DTFilterOutputStream3 // expected-warning {{cannot find interface declaration for 'DTFilterOutputStream3'}}
|
|
|
|
- (id)initWithNextOutputStream:(id <DTOutputStreams>) outputStream {
|
2009-03-04 18:11:40 +03:00
|
|
|
id <DTOutputStreams> nextOutputStream = [self nextOutputStream]; // expected-warning {{method '-nextOutputStream' not found (return type defaults to 'id')}}
|
2008-06-01 03:10:15 +04:00
|
|
|
// GCC warns about both of these as well (no errors).
|
2008-10-15 02:18:38 +04:00
|
|
|
self = nextOutputStream; // expected-warning {{incompatible type assigning 'id<DTOutputStreams>', expected 'DTFilterOutputStream3 *'}}
|
2008-09-03 21:53:25 +04:00
|
|
|
return nextOutputStream ? nextOutputStream : self;
|
2008-06-01 03:10:15 +04:00
|
|
|
}
|
|
|
|
@end
|
2009-07-17 01:55:48 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
@protocol P0
|
|
|
|
@property int intProp;
|
|
|
|
@end
|
|
|
|
@protocol P1
|
|
|
|
@end
|
|
|
|
@protocol P2
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface A <P0>
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface B : A
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface C
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface D
|
|
|
|
@end
|
|
|
|
|
|
|
|
void f0(id<P0> x) {
|
|
|
|
x.intProp = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void f1(int cond, id<P0> x, id<P0> y) {
|
|
|
|
(cond ? x : y).intProp = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void f2(int cond, id<P0> x, A *y) {
|
|
|
|
(cond ? x : y).intProp = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void f3(int cond, id<P0> x, B *y) {
|
|
|
|
(cond ? x : y).intProp = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void f4(int cond, id x, B *y) {
|
|
|
|
(cond ? x : y).intProp = 1; // expected-error {{property 'intProp' not found on object of type 'id'}}
|
|
|
|
}
|
|
|
|
|
|
|
|
void f5(int cond, id<P0> x, C *y) {
|
|
|
|
(cond ? x : y).intProp = 1; // expected-error {{property 'intProp' not found on object of type 'C *'}}
|
|
|
|
}
|
|
|
|
|
|
|
|
void f6(int cond, C *x, D *y) {
|
|
|
|
(cond ? x : y).intProp = 1; // expected-warning {{incompatible operand types}}, expected-error {{property 'intProp' not found on object of type 'id'}}
|
|
|
|
}
|