Skip to content

Commit 92e7ad7

Browse files
committed
Add a release note and test cases for const and volatile pointers
1 parent 1a5777d commit 92e7ad7

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,9 @@ Non-comprehensive list of changes in this release
325325
``__reference_constructs_from_temporary`` should be used instead. (#GH44056)
326326
- Added `__builtin_get_vtable_pointer` to directly load the primary vtable pointer from a
327327
polymorphic object.
328+
- Clang no longer rejects reinterpret_cast conversions between indirect
329+
ARC-managed pointers and other pointer types. The prior behavior was overly
330+
strict and inconsistent with the ARC specification.
328331

329332
New Compiler Flags
330333
------------------

clang/test/SemaObjCXX/arc-type-conversion.mm

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,17 @@ void test_reinterpret_cast(__strong id *sip, __weak id *wip,
7676
(void)reinterpret_cast<__weak id *>(csip); // expected-error{{reinterpret_cast from '__strong id const *' to '__weak id *' casts away qualifiers}}
7777
(void)reinterpret_cast<__strong id *>(cwip); // expected-error{{reinterpret_cast from '__weak id const *' to '__strong id *' casts away qualifiers}}
7878

79-
auto *p0 = reinterpret_cast<unsigned long *>(sip);
80-
(void)reinterpret_cast<__strong id *>(p0);
81-
auto *p1 = reinterpret_cast<__weak NSString *>(sip);
82-
(void)reinterpret_cast<__strong id *>(p1);
79+
auto *ul = reinterpret_cast<unsigned long *>(sip);
80+
(void)reinterpret_cast<__strong id *>(ul);
81+
auto *wp = reinterpret_cast<__weak NSString *>(sip);
82+
(void)reinterpret_cast<__strong id *>(wp);
8383
(void)reinterpret_cast<unsigned long *>(csip); // expected-error {{reinterpret_cast from '__strong id const *' to 'unsigned long *' casts away qualifiers}}
84-
const unsigned long *p2 = nullptr;
85-
(void)reinterpret_cast<__strong id *>(p2); // expected-error {{reinterpret_cast from 'const unsigned long *' to '__strong id *' casts away qualifiers}}
84+
const unsigned long *cul = nullptr;
85+
(void)reinterpret_cast<__strong id *>(cul); // expected-error {{reinterpret_cast from 'const unsigned long *' to '__strong id *' casts away qualifiers}}
86+
volatile __strong id *vsip = nullptr;
87+
(void)reinterpret_cast<unsigned long *>(vsip); // expected-error {{reinterpret_cast from '__strong id volatile *' to 'unsigned long *' casts away qualifiers}}
88+
volatile unsigned long *vul = nullptr;
89+
(void)reinterpret_cast<__strong id *>(vul); // expected-error {{reinterpret_cast from 'volatile unsigned long *' to '__strong id *' casts away qualifiers}}
8690
auto uip = reinterpret_cast<uintptr_t>(sip);
8791
(void)reinterpret_cast<__strong id *>(uip); // expected-error {{to '__strong id *' is disallowed with ARC}}
8892
}

0 commit comments

Comments
 (0)