diff options
| author | James Y Knight <jyknight@google.com> | 2019-11-04 12:44:31 -0500 |
|---|---|---|
| committer | James Y Knight <jyknight@google.com> | 2019-11-04 16:26:53 -0500 |
| commit | d11a9018b773c0359934a7989d886b02468112e4 (patch) | |
| tree | a879b9951a76abd9ed76bb44b0b24cfd80d9cce2 /clang | |
| parent | 8bbf2e37167d9ac08fa9d3c772d48ca7d9a6f8f6 (diff) | |
| download | bcm5719-llvm-d11a9018b773c0359934a7989d886b02468112e4.tar.gz bcm5719-llvm-d11a9018b773c0359934a7989d886b02468112e4.zip | |
Add release notes for commit ccc4d83cda16bea1d9dfd0967dc7d2cfb24b8e75.
(Which was "[ObjC] Diagnose implicit type coercion from ObjC 'Class'
to object pointer types.")
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/docs/ReleaseNotes.rst | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 5363050ca69..51bcd013df6 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 ---------------------------------- |

