|
1 | 1 | // RUN: %clang_cc1 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify -fblocks %s |
2 | 2 |
|
| 3 | +@class NSString; |
| 4 | +typedef unsigned __INTPTR_TYPE__ uintptr_t; |
| 5 | + |
3 | 6 | void * cvt(id arg) // expected-note{{candidate function not viable: cannot convert argument of incomplete type 'void *' to '__strong id'}} |
4 | 7 | { |
5 | 8 | void* voidp_val; |
@@ -72,6 +75,24 @@ void test_reinterpret_cast(__strong id *sip, __weak id *wip, |
72 | 75 | (void)reinterpret_cast<__weak id *>(cwip); // expected-error{{reinterpret_cast from '__weak id const *' to '__weak id *' casts away qualifiers}} |
73 | 76 | (void)reinterpret_cast<__weak id *>(csip); // expected-error{{reinterpret_cast from '__strong id const *' to '__weak id *' casts away qualifiers}} |
74 | 77 | (void)reinterpret_cast<__strong id *>(cwip); // expected-error{{reinterpret_cast from '__weak id const *' to '__strong id *' casts away qualifiers}} |
| 78 | + |
| 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); |
| 83 | + (void)reinterpret_cast<unsigned long *>(csip); // expected-error {{reinterpret_cast from '__strong id const *' to 'unsigned long *' casts away qualifiers}} |
| 84 | + (void)reinterpret_cast<const unsigned long *>(csip); |
| 85 | + const unsigned long *cul = nullptr; |
| 86 | + (void)reinterpret_cast<__strong id *>(cul); // expected-error {{reinterpret_cast from 'const unsigned long *' to '__strong id *' casts away qualifiers}} |
| 87 | + (void)reinterpret_cast<const __strong id *>(cul); |
| 88 | + volatile __strong id *vsip = nullptr; |
| 89 | + (void)reinterpret_cast<unsigned long *>(vsip); // expected-error {{reinterpret_cast from '__strong id volatile *' to 'unsigned long *' casts away qualifiers}} |
| 90 | + (void)reinterpret_cast<volatile unsigned long *>(vsip); |
| 91 | + volatile unsigned long *vul = nullptr; |
| 92 | + (void)reinterpret_cast<__strong id *>(vul); // expected-error {{reinterpret_cast from 'volatile unsigned long *' to '__strong id *' casts away qualifiers}} |
| 93 | + (void)reinterpret_cast<volatile __strong id *>(vul); |
| 94 | + auto uip = reinterpret_cast<uintptr_t>(sip); |
| 95 | + (void)reinterpret_cast<__strong id *>(uip); // expected-error {{to '__strong id *' is disallowed with ARC}} |
75 | 96 | } |
76 | 97 |
|
77 | 98 | void test_cstyle_cast(__strong id *sip, __weak id *wip, |
@@ -194,8 +215,6 @@ void from_void(void *vp) { |
194 | 215 | typedef void (^Block_strong)() __strong; |
195 | 216 | typedef void (^Block_autoreleasing)() __autoreleasing; |
196 | 217 |
|
197 | | -@class NSString; |
198 | | - |
199 | 218 | void ownership_transfer_in_cast(void *vp, Block *pblk) { |
200 | 219 | __strong NSString **sip2 = static_cast<NSString **>(static_cast<__strong id *>(vp)); |
201 | 220 | __strong NSString **&si2pref = static_cast<NSString **&>(sip2); |
|
0 commit comments