1 | //===----------------------------------------------------------------------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | // UNSUPPORTED: c++03 |
10 | // REQUIRES: has-fobjc-arc |
11 | // ADDITIONAL_COMPILE_FLAGS: -fobjc-arc |
12 | |
13 | // <type_traits> |
14 | |
15 | // std::is_pointer |
16 | |
17 | // Test that we correctly handle Objective-C++ ARC qualifiers on pointers. |
18 | |
19 | #include <type_traits> |
20 | #include "test_macros.h" |
21 | |
22 | |
23 | template <typename T> |
24 | void assert_is_pointer() { |
25 | static_assert(std::is_pointer<T>::value, "" ); |
26 | #if TEST_STD_VER > 14 |
27 | static_assert(std::is_pointer_v<T>, "" ); |
28 | #endif |
29 | } |
30 | |
31 | template <typename T> |
32 | void test_is_pointer() { |
33 | assert_is_pointer<T>(); |
34 | |
35 | assert_is_pointer<T __weak>(); |
36 | assert_is_pointer<T __strong>(); |
37 | assert_is_pointer<T __autoreleasing>(); |
38 | assert_is_pointer<T __unsafe_unretained>(); |
39 | |
40 | assert_is_pointer<T __weak const>(); |
41 | assert_is_pointer<T __strong const>(); |
42 | assert_is_pointer<T __autoreleasing const>(); |
43 | assert_is_pointer<T __unsafe_unretained const>(); |
44 | |
45 | assert_is_pointer<T __weak volatile>(); |
46 | assert_is_pointer<T __strong volatile>(); |
47 | assert_is_pointer<T __autoreleasing volatile>(); |
48 | assert_is_pointer<T __unsafe_unretained volatile>(); |
49 | |
50 | assert_is_pointer<T __weak const volatile>(); |
51 | assert_is_pointer<T __strong const volatile>(); |
52 | assert_is_pointer<T __autoreleasing const volatile>(); |
53 | assert_is_pointer<T __unsafe_unretained const volatile>(); |
54 | } |
55 | |
56 | @class Foo; |
57 | |
58 | int main(int, char**) { |
59 | test_is_pointer<id>(); |
60 | test_is_pointer<id const>(); |
61 | test_is_pointer<id volatile>(); |
62 | test_is_pointer<id const volatile>(); |
63 | |
64 | test_is_pointer<Foo*>(); |
65 | test_is_pointer<Foo const*>(); |
66 | test_is_pointer<Foo volatile*>(); |
67 | test_is_pointer<Foo const volatile*>(); |
68 | |
69 | test_is_pointer<void*>(); |
70 | test_is_pointer<void const*>(); |
71 | test_is_pointer<void volatile*>(); |
72 | test_is_pointer<void const volatile*>(); |
73 | |
74 | return 0; |
75 | } |
76 | |