[cfe-commits] r100533 - in /cfe/trunk: lib/AST/ASTContext.cpp test/SemaObjC/block-type-safety.m
Fariborz Jahanian
fjahanian at apple.com
Tue Apr 6 10:23:39 PDT 2010
Author: fjahanian
Date: Tue Apr 6 12:23:39 2010
New Revision: 100533
URL: http://llvm.org/viewvc/llvm-project?rev=100533&view=rev
Log:
Put type restriction on convesion to nonconforming 'id' back in
block pointer type comparison.
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/SemaObjC/block-type-safety.m
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=100533&r1=100532&r2=100533&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Apr 6 12:23:39 2010
@@ -4136,15 +4136,14 @@
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);
Modified: cfe/trunk/test/SemaObjC/block-type-safety.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/block-type-safety.m?rev=100533&r1=100532&r2=100533&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/block-type-safety.m (original)
+++ cfe/trunk/test/SemaObjC/block-type-safety.m Tue Apr 6 12:23:39 2010
@@ -94,3 +94,13 @@
}
@end
+ at 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>)'}}
+}
+
More information about the cfe-commits
mailing list