[PATCH] D44580: Sema: allow comparison between blocks & block-compatible objc types

David Chisnall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 17 01:58:58 PDT 2018


theraven added a comment.

We seem to be missing tests for the assignment part of this patch.



================
Comment at: lib/Sema/SemaExpr.cpp:7749
+    // id (or strictly compatible object type) -> T^
+    if (getLangOpts().ObjC1 && RHSType->isBlockCompatibleObjCPointerType(Context)) {
       Kind = CK_AnyPointerToBlockPointerCast;
----------------
Do we want to allow implicit casts for all object types to block types for assignment, or only for null pointers?  We definitely want to allow `nil` to be assigned to a block type, but I would lean slightly to requiring an implicit cast.

Ideally, I think we'd allow this but warn, because casting from an arbitrary ObjC type to a block incorrectly can cause exciting security vulnerabilities if it's done incorrectly and we should encourage people to check these casts (`nil` is always safe though - as long as somewhere else checks the nullability attributes).


Repository:
  rC Clang

https://reviews.llvm.org/D44580





More information about the cfe-commits mailing list