[clang] d11a901 - Add release notes for commit ccc4d83cda16bea1d9dfd0967dc7d2cfb24b8e75.

James Y Knight via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 4 13:28:40 PST 2019


Author: James Y Knight
Date: 2019-11-04T16:26:53-05:00
New Revision: d11a9018b773c0359934a7989d886b02468112e4

URL: https://github.com/llvm/llvm-project/commit/d11a9018b773c0359934a7989d886b02468112e4
DIFF: https://github.com/llvm/llvm-project/commit/d11a9018b773c0359934a7989d886b02468112e4.diff

LOG: Add release notes for commit ccc4d83cda16bea1d9dfd0967dc7d2cfb24b8e75.

(Which was "[ObjC] Diagnose implicit type coercion from ObjC 'Class'
to object pointer types.")

Added: 
    

Modified: 
    clang/docs/ReleaseNotes.rst

Removed: 
    


################################################################################
diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5363050ca69d..51bcd013df6d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -166,7 +166,49 @@ C++1z Feature Support
 Objective-C Language Changes in Clang
 -------------------------------------
 
-- ...
+- In both Objective-C and
+  Objective-C++, ``-Wcompare-distinct-pointer-types`` will now warn when
+  comparing ObjC ``Class`` with an ObjC instance type pointer.
+
+  .. code-block:: objc
+
+    Class clz = ...;
+    MyType *instance = ...;
+    bool eq = (clz == instance); // Previously undiagnosed, now warns.
+
+- Objective-C++ now diagnoses conversions between ``Class`` and ObjC
+  instance type pointers. Such conversions already emitted an
+  on-by-default ``-Wincompatible-pointer-types`` warning in Objective-C
+  mode, but had inadvertently been missed entirely in
+  Objective-C++. This has been fixed, and they are now diagnosed as
+  errors, consistent with the usual C++ treatment for conversions
+  between unrelated pointer types.
+
+  .. code-block:: objc
+
+    Class clz = ...;
+    MyType *instance = ...;
+    clz = instance; // Previously undiagnosed, now an error.
+    instance = clz; // Previously undiagnosed, now an error.
+
+  One particular issue you may run into is attempting to use a class
+  as a key in a dictionary literal. This will now result in an error,
+  because ``Class`` is not convertable to ``id<NSCopying>``. (Note that
+  this was already a warning in Objective-C mode.) While an arbitrary
+  ``Class`` object is not guaranteed to implement ``NSCopying``, the
+  default metaclass implementation does. Therefore, the recommended
+  solution is to insert an explicit cast to ``id``, which disables the
+  type-checking here.
+
+ .. code-block:: objc
+
+    Class cls = ...;
+
+    // Error: cannot convert from Class to id<NSCoding>.
+    NSDictionary* d = @{cls : @"Hello"};
+
+    // Fix: add an explicit cast to 'id'.
+    NSDictionary* d = @{(id)cls : @"Hello"};
 
 OpenCL C Language Changes in Clang
 ----------------------------------


        


More information about the cfe-commits mailing list