diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-04-06 17:23:39 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-04-06 17:23:39 +0000 |
commit | 440a6832c5b3823eb730719f997e2866e504a274 (patch) | |
tree | ded36b9f1ad73ebc797f520cfa058464b6325281 | |
parent | a910f17a208c528d9da622f8a7aaa9f85e2e3c68 (diff) | |
download | bcm5719-llvm-440a6832c5b3823eb730719f997e2866e504a274.tar.gz bcm5719-llvm-440a6832c5b3823eb730719f997e2866e504a274.zip |
Put type restriction on convesion to nonconforming 'id' back in
block pointer type comparison.
llvm-svn: 100533
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 5 | ||||
-rw-r--r-- | clang/test/SemaObjC/block-type-safety.m | 10 |
2 files changed, 12 insertions, 3 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index c77acce1bd0..f265f8e8a70 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -4136,15 +4136,14 @@ bool ASTContext::canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, bool ASTContext::canAssignObjCInterfacesInBlockPointer( const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT) { - if (RHSOPT->isObjCBuiltinType() || - LHSOPT->isObjCIdType() || LHSOPT->isObjCQualifiedIdType()) + if (RHSOPT->isObjCBuiltinType() || LHSOPT->isObjCIdType()) return true; if (LHSOPT->isObjCBuiltinType()) { return RHSOPT->isObjCBuiltinType() || RHSOPT->isObjCQualifiedIdType(); } - if (RHSOPT->isObjCQualifiedIdType()) + if (LHSOPT->isObjCQualifiedIdType() || RHSOPT->isObjCQualifiedIdType()) return ObjCQualifiedIdTypesAreCompatible(QualType(LHSOPT,0), QualType(RHSOPT,0), false); diff --git a/clang/test/SemaObjC/block-type-safety.m b/clang/test/SemaObjC/block-type-safety.m index b40f9b09358..0df8c675ed9 100644 --- a/clang/test/SemaObjC/block-type-safety.m +++ b/clang/test/SemaObjC/block-type-safety.m @@ -94,3 +94,13 @@ void test2(void) } @end +@protocol P, P2; +void f4(void (^f)(id<P> x)) { + NSArray<P2> *b; + f(b); // expected-warning {{incompatible type passing 'NSArray<P2> *', expected 'id<P>'}} +} + +void test3() { + f4(^(NSArray<P2>* a) { }); // expected-error {{incompatible block pointer types passing 'void (^)(NSArray<P2> *)', expected 'void (^)(id<P>)'}} +} + |