diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2014-10-13 21:07:45 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2014-10-13 21:07:45 +0000 |
commit | 12f7ef39ce36dc712387bb0a14fe7e4714138eb7 (patch) | |
tree | e788d0d348c5ce47510434a41793548117973af7 /clang/test/SemaObjC | |
parent | b44ad60835fd3663e135ed231a5791f4efc21861 (diff) | |
download | bcm5719-llvm-12f7ef39ce36dc712387bb0a14fe7e4714138eb7.tar.gz bcm5719-llvm-12f7ef39ce36dc712387bb0a14fe7e4714138eb7.zip |
Objective-C [Sema]. Fixes a bug in comparing qualified
Objective-C pointer types. In this case, checker incorrectly
claims incompatible pointer types if redundant protocol conformance
is specified. rdar://18491222
llvm-svn: 219630
Diffstat (limited to 'clang/test/SemaObjC')
-rw-r--r-- | clang/test/SemaObjC/compare-qualified-class.m | 35 | ||||
-rw-r--r-- | clang/test/SemaObjC/conditional-expr.m | 10 |
2 files changed, 40 insertions, 5 deletions
diff --git a/clang/test/SemaObjC/compare-qualified-class.m b/clang/test/SemaObjC/compare-qualified-class.m index 60ef851e1f3..a5256152144 100644 --- a/clang/test/SemaObjC/compare-qualified-class.m +++ b/clang/test/SemaObjC/compare-qualified-class.m @@ -28,3 +28,38 @@ int main () { classA == classD; // expected-warning {{comparison of distinct pointer types ('Class<SomeProtocol>' and 'Class<SomeProtocol1>')}} } +// rdar://18491222 +@protocol NSObject @end + +@interface NSObject @end +@protocol ProtocolX <NSObject> +@end + +@protocol ProtocolY <NSObject> +@end + +@interface ClassA : NSObject +@end + +@interface ClassB : ClassA <ProtocolY, ProtocolX> +@end + +@interface OtherClass : NSObject +@property (nonatomic, copy) ClassB<ProtocolX> *aProperty; +- (ClassA<ProtocolY> *)aMethod; +- (ClassA<ProtocolY> *)anotherMethod; +@end + +@implementation OtherClass +- (ClassA<ProtocolY> *)aMethod { + // This does not work, even though ClassB subclasses from A and conforms to Y + // because the property type explicity adds ProtocolX conformance + // even though ClassB already conforms to ProtocolX + return self.aProperty; +} +- (ClassA<ProtocolY> *)anotherMethod { + // This works, even though all it is doing is removing an explicit + // protocol conformance that ClassB already conforms to + return (ClassB *)self.aProperty; +} +@end diff --git a/clang/test/SemaObjC/conditional-expr.m b/clang/test/SemaObjC/conditional-expr.m index d8862c584a0..71e108cce67 100644 --- a/clang/test/SemaObjC/conditional-expr.m +++ b/clang/test/SemaObjC/conditional-expr.m @@ -101,10 +101,10 @@ int f8(int a, A<P0> *x, A *y) { } void f9(int a, A<P0> *x, A<P1> *y) { - id l0 = (a ? x : y ); // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}} - A<P0> *l1 = (a ? x : y ); // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}} - A<P1> *l2 = (a ? x : y ); // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}} - [ (a ? x : y ) intProp ]; // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}} + id l0 = (a ? x : y ); // Ok. y is of A<P1> object type and A is qualified by P0. + A<P0> *l1 = (a ? x : y ); // Ok. y is of A<P1> object type and A is qualified by P0. + A<P1> *l2 = (a ? x : y ); // expected-warning {{incompatible pointer types initializing 'A<P1> *' with an expression of type 'A<P0> *'}} + (void)[ (a ? x : y ) intProp ]; // Ok. Common type is A<P0> * and P0's property intProp is accessed. } void f10(int a, id<P0> x, id y) { @@ -116,5 +116,5 @@ void f11(int a, id<P0> x, id<P1> y) { } void f12(int a, A<P0> *x, A<P1> *y) { - A<P1>* l0 = (a ? x : y ); // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}} + A<P1>* l0 = (a ? x : y ); // expected-warning {{incompatible pointer types initializing 'A<P1> *' with an expression of type 'A<P0> *'}} } |