1 | // RUN: %clang_cc1 -fsyntax-only -fobjc-weak -fobjc-runtime-has-weak -verify -std=c++11 %s |
2 | // expected-no-diagnostics |
3 | |
4 | // Check the results of the various type-trait query functions on |
5 | // lifetime-qualified types in ObjC Weak. |
6 | |
7 | #define TRAIT_IS_TRUE(Trait, Type) static_assert(Trait(Type), "") |
8 | #define TRAIT_IS_FALSE(Trait, Type) static_assert(!Trait(Type), "") |
9 | #define TRAIT_IS_TRUE_2(Trait, Type1, Type2) static_assert(Trait(Type1, Type2), "") |
10 | #define TRAIT_IS_FALSE_2(Trait, Type1, Type2) static_assert(!Trait(Type1, Type2), "") |
11 | |
12 | struct HasStrong { id obj; }; |
13 | struct HasWeak { __weak id obj; }; |
14 | struct HasUnsafeUnretained { __unsafe_unretained id obj; }; |
15 | |
16 | // __has_nothrow_assign |
17 | TRAIT_IS_TRUE(__has_nothrow_assign, __strong id); |
18 | TRAIT_IS_TRUE(__has_nothrow_assign, __weak id); |
19 | TRAIT_IS_TRUE(__has_nothrow_assign, __autoreleasing id); |
20 | TRAIT_IS_TRUE(__has_nothrow_assign, __unsafe_unretained id); |
21 | TRAIT_IS_TRUE(__has_nothrow_assign, HasStrong); |
22 | TRAIT_IS_TRUE(__has_nothrow_assign, HasWeak); |
23 | TRAIT_IS_TRUE(__has_nothrow_assign, HasUnsafeUnretained); |
24 | |
25 | // __has_nothrow_copy |
26 | TRAIT_IS_TRUE(__has_nothrow_copy, __strong id); |
27 | TRAIT_IS_TRUE(__has_nothrow_copy, __weak id); |
28 | TRAIT_IS_TRUE(__has_nothrow_copy, __autoreleasing id); |
29 | TRAIT_IS_TRUE(__has_nothrow_copy, __unsafe_unretained id); |
30 | TRAIT_IS_TRUE(__has_nothrow_copy, HasStrong); |
31 | TRAIT_IS_TRUE(__has_nothrow_copy, HasWeak); |
32 | TRAIT_IS_TRUE(__has_nothrow_copy, HasUnsafeUnretained); |
33 | |
34 | // __has_nothrow_constructor |
35 | TRAIT_IS_TRUE(__has_nothrow_constructor, __strong id); |
36 | TRAIT_IS_TRUE(__has_nothrow_constructor, __weak id); |
37 | TRAIT_IS_TRUE(__has_nothrow_constructor, __autoreleasing id); |
38 | TRAIT_IS_TRUE(__has_nothrow_constructor, __unsafe_unretained id); |
39 | TRAIT_IS_TRUE(__has_nothrow_constructor, HasStrong); |
40 | TRAIT_IS_TRUE(__has_nothrow_constructor, HasWeak); |
41 | TRAIT_IS_TRUE(__has_nothrow_constructor, HasUnsafeUnretained); |
42 | |
43 | // __has_trivial_assign |
44 | TRAIT_IS_TRUE(__has_trivial_assign, __strong id); |
45 | TRAIT_IS_FALSE(__has_trivial_assign, __weak id); |
46 | TRAIT_IS_TRUE(__has_trivial_assign, __autoreleasing id); |
47 | TRAIT_IS_TRUE(__has_trivial_assign, __unsafe_unretained id); |
48 | TRAIT_IS_TRUE(__has_trivial_assign, HasStrong); |
49 | TRAIT_IS_FALSE(__has_trivial_assign, HasWeak); |
50 | TRAIT_IS_TRUE(__has_trivial_assign, HasUnsafeUnretained); |
51 | |
52 | // __has_trivial_copy |
53 | TRAIT_IS_TRUE(__has_trivial_copy, __strong id); |
54 | TRAIT_IS_FALSE(__has_trivial_copy, __weak id); |
55 | TRAIT_IS_TRUE(__has_trivial_copy, __autoreleasing id); |
56 | TRAIT_IS_TRUE(__has_trivial_copy, __unsafe_unretained id); |
57 | TRAIT_IS_TRUE(__has_trivial_copy, HasStrong); |
58 | TRAIT_IS_FALSE(__has_trivial_copy, HasWeak); |
59 | TRAIT_IS_TRUE(__has_trivial_copy, HasUnsafeUnretained); |
60 | |
61 | // __has_trivial_constructor |
62 | TRAIT_IS_TRUE(__has_trivial_constructor, __strong id); |
63 | TRAIT_IS_FALSE(__has_trivial_constructor, __weak id); |
64 | TRAIT_IS_TRUE(__has_trivial_constructor, __autoreleasing id); |
65 | TRAIT_IS_TRUE(__has_trivial_constructor, __unsafe_unretained id); |
66 | TRAIT_IS_TRUE(__has_trivial_constructor, HasStrong); |
67 | TRAIT_IS_FALSE(__has_trivial_constructor, HasWeak); |
68 | TRAIT_IS_TRUE(__has_trivial_constructor, HasUnsafeUnretained); |
69 | |
70 | // __has_trivial_destructor |
71 | TRAIT_IS_TRUE(__has_trivial_destructor, __strong id); |
72 | TRAIT_IS_FALSE(__has_trivial_destructor, __weak id); |
73 | TRAIT_IS_TRUE(__has_trivial_destructor, __autoreleasing id); |
74 | TRAIT_IS_TRUE(__has_trivial_destructor, __unsafe_unretained id); |
75 | TRAIT_IS_TRUE(__has_trivial_destructor, HasStrong); |
76 | TRAIT_IS_FALSE(__has_trivial_destructor, HasWeak); |
77 | TRAIT_IS_TRUE(__has_trivial_destructor, HasUnsafeUnretained); |
78 | |
79 | // __is_literal |
80 | TRAIT_IS_TRUE(__is_literal, __strong id); |
81 | TRAIT_IS_TRUE(__is_literal, __weak id); |
82 | TRAIT_IS_TRUE(__is_literal, __autoreleasing id); |
83 | TRAIT_IS_TRUE(__is_literal, __unsafe_unretained id); |
84 | |
85 | // __is_literal_type |
86 | TRAIT_IS_TRUE(__is_literal_type, __strong id); |
87 | TRAIT_IS_TRUE(__is_literal_type, __weak id); |
88 | TRAIT_IS_TRUE(__is_literal_type, __autoreleasing id); |
89 | TRAIT_IS_TRUE(__is_literal_type, __unsafe_unretained id); |
90 | |
91 | // __is_pod |
92 | TRAIT_IS_TRUE(__is_pod, __strong id); |
93 | TRAIT_IS_FALSE(__is_pod, __weak id); |
94 | TRAIT_IS_TRUE(__is_pod, __autoreleasing id); |
95 | TRAIT_IS_TRUE(__is_pod, __unsafe_unretained id); |
96 | TRAIT_IS_TRUE(__is_pod, HasStrong); |
97 | TRAIT_IS_FALSE(__is_pod, HasWeak); |
98 | TRAIT_IS_TRUE(__is_pod, HasUnsafeUnretained); |
99 | |
100 | // __is_trivial |
101 | TRAIT_IS_TRUE(__is_trivial, __strong id); |
102 | TRAIT_IS_FALSE(__is_trivial, __weak id); |
103 | TRAIT_IS_TRUE(__is_trivial, __autoreleasing id); |
104 | TRAIT_IS_TRUE(__is_trivial, __unsafe_unretained id); |
105 | TRAIT_IS_TRUE(__is_trivial, HasStrong); |
106 | TRAIT_IS_FALSE(__is_trivial, HasWeak); |
107 | TRAIT_IS_TRUE(__is_trivial, HasUnsafeUnretained); |
108 | |
109 | // __is_scalar |
110 | TRAIT_IS_TRUE(__is_scalar, __strong id); |
111 | TRAIT_IS_FALSE(__is_scalar, __weak id); |
112 | TRAIT_IS_TRUE(__is_scalar, __autoreleasing id); |
113 | TRAIT_IS_TRUE(__is_scalar, __unsafe_unretained id); |
114 | |
115 | // __is_standard_layout |
116 | TRAIT_IS_TRUE(__is_standard_layout, __strong id); |
117 | TRAIT_IS_TRUE(__is_standard_layout, __weak id); |
118 | TRAIT_IS_TRUE(__is_standard_layout, __autoreleasing id); |
119 | TRAIT_IS_TRUE(__is_standard_layout, __unsafe_unretained id); |
120 | |
121 | // __is_trivally_assignable |
122 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __strong id&, __strong id); |
123 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __strong id&, __weak id); |
124 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __strong id&, __autoreleasing id); |
125 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __strong id&, __unsafe_unretained id); |
126 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __strong id&, __strong id&&); |
127 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __strong id&, __weak id&&); |
128 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __strong id&, __autoreleasing id&&); |
129 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __strong id&, __unsafe_unretained id&&); |
130 | TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __strong id); |
131 | TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __weak id); |
132 | TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __autoreleasing id); |
133 | TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __unsafe_unretained id); |
134 | TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __strong id&&); |
135 | TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __weak id&&); |
136 | TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __autoreleasing id&&); |
137 | TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __unsafe_unretained id&&); |
138 | |
139 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __autoreleasing id&, __strong id); |
140 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __autoreleasing id&, __weak id); |
141 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __autoreleasing id&, __autoreleasing id); |
142 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __autoreleasing id&, __unsafe_unretained id); |
143 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __autoreleasing id&, __strong id&&); |
144 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __autoreleasing id&, __weak id&&); |
145 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __autoreleasing id&, __autoreleasing id&&); |
146 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __autoreleasing id&, __unsafe_unretained id&&); |
147 | |
148 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __strong id); |
149 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __weak id); |
150 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __autoreleasing id); |
151 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __unsafe_unretained id); |
152 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __strong id&&); |
153 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __weak id&&); |
154 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __autoreleasing id&&); |
155 | TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __unsafe_unretained id&&); |
156 | |
157 | TRAIT_IS_TRUE_2(__is_trivially_assignable, HasStrong&, HasStrong); |
158 | TRAIT_IS_TRUE_2(__is_trivially_assignable, HasStrong&, HasStrong&&); |
159 | TRAIT_IS_FALSE_2(__is_trivially_assignable, HasWeak&, HasWeak); |
160 | TRAIT_IS_FALSE_2(__is_trivially_assignable, HasWeak&, HasWeak&&); |
161 | TRAIT_IS_TRUE_2(__is_trivially_assignable, HasUnsafeUnretained&, HasUnsafeUnretained); |
162 | TRAIT_IS_TRUE_2(__is_trivially_assignable, HasUnsafeUnretained&, HasUnsafeUnretained&&); |
163 | |
164 | // __is_trivally_constructible |
165 | TRAIT_IS_TRUE(__is_trivially_constructible, __strong id); |
166 | TRAIT_IS_FALSE(__is_trivially_constructible, __weak id); |
167 | TRAIT_IS_TRUE(__is_trivially_constructible, __autoreleasing id); |
168 | TRAIT_IS_TRUE(__is_trivially_constructible, __unsafe_unretained id); |
169 | |
170 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __strong id, __strong id); |
171 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __strong id, __weak id); |
172 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __strong id, __autoreleasing id); |
173 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __strong id, __unsafe_unretained id); |
174 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __strong id, __strong id&&); |
175 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __strong id, __weak id&&); |
176 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __strong id, __autoreleasing id&&); |
177 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __strong id, __unsafe_unretained id&&); |
178 | TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __strong id); |
179 | TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __weak id); |
180 | TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __autoreleasing id); |
181 | TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __unsafe_unretained id); |
182 | TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __strong id&&); |
183 | TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __weak id&&); |
184 | TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __autoreleasing id&&); |
185 | TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __unsafe_unretained id&&); |
186 | |
187 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __autoreleasing id, __strong id); |
188 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __autoreleasing id, __weak id); |
189 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __autoreleasing id, __autoreleasing id); |
190 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __autoreleasing id, __unsafe_unretained id); |
191 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __autoreleasing id, __strong id&&); |
192 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __autoreleasing id, __weak id&&); |
193 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __autoreleasing id, __autoreleasing id&&); |
194 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __autoreleasing id, __unsafe_unretained id&&); |
195 | |
196 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __strong id); |
197 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __weak id); |
198 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __autoreleasing id); |
199 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __unsafe_unretained id); |
200 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __strong id&&); |
201 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __weak id&&); |
202 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __autoreleasing id&&); |
203 | TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __unsafe_unretained id&&); |
204 | |
205 | TRAIT_IS_TRUE_2(__is_trivially_constructible, HasStrong, HasStrong); |
206 | TRAIT_IS_TRUE_2(__is_trivially_constructible, HasStrong, HasStrong&&); |
207 | TRAIT_IS_FALSE_2(__is_trivially_constructible, HasWeak, HasWeak); |
208 | TRAIT_IS_FALSE_2(__is_trivially_constructible, HasWeak, HasWeak&&); |
209 | TRAIT_IS_TRUE_2(__is_trivially_constructible, HasUnsafeUnretained, HasUnsafeUnretained); |
210 | TRAIT_IS_TRUE_2(__is_trivially_constructible, HasUnsafeUnretained, HasUnsafeUnretained&&); |
211 | |