diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -8501,7 +8501,11 @@ if (LHSOPT->isObjCQualifiedIdType() || RHSOPT->isObjCQualifiedIdType()) { if (getLangOpts().CompatibilityQualifiedIdBlockParamTypeChecking) - return finish(ObjCQualifiedIdTypesAreCompatible(LHSOPT, RHSOPT, false)); + // Use for block parameters previous type checking for compatibility. + return finish(ObjCQualifiedIdTypesAreCompatible(LHSOPT, RHSOPT, false) || + // Or corrected type checking as in non-compat mode. + (!BlockReturnType && + ObjCQualifiedIdTypesAreCompatible(RHSOPT, LHSOPT, false))); else return finish(ObjCQualifiedIdTypesAreCompatible( (BlockReturnType ? LHSOPT : RHSOPT), diff --git a/clang/test/SemaObjC/block-type-safety.m b/clang/test/SemaObjC/block-type-safety.m --- a/clang/test/SemaObjC/block-type-safety.m +++ b/clang/test/SemaObjC/block-type-safety.m @@ -167,7 +167,7 @@ void (^blockWithParam)(NSAllArray *); void (^genericBlockWithParam)(id); genericBlockWithParam = blockWithParam; - blockWithParam = genericBlockWithParam; // expected-error {{incompatible block pointer types assigning to 'void (^)(NSAllArray *)' from 'void (^)(id)'}} + blockWithParam = genericBlockWithParam; return 0; } #endif