1 // RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++98 %s
2 // RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++11 %s
3 // RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++17 %s
4 // RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=gnu++17 %s
5
6 namespace std {
7 struct type_info;
8 }
9
10 typedef __SVInt8_t svint8_t;
11 typedef __SVInt16_t svint16_t;
12
13 svint8_t global_int8; // expected-error {{non-local variable with sizeless type 'svint8_t'}}
14 extern svint8_t extern_int8; // expected-error {{non-local variable with sizeless type 'svint8_t'}}
15 static svint8_t static_int8; // expected-error {{non-local variable with sizeless type 'svint8_t'}}
16 __thread svint8_t thread_int8; // expected-error {{non-local variable with sizeless type 'svint8_t'}}
17 svint8_t *global_int8_ptr;
18 extern svint8_t *extern_int8_ptr;
19 static svint8_t *static_int8_ptr;
20
21 typedef svint8_t int8_typedef;
22 typedef svint8_t *int8_ptr_typedef;
23
24 int sizeof_int8 = sizeof(svint8_t); // expected-error {{invalid application of 'sizeof' to sizeless type 'svint8_t'}}
25 int sizeof_int8_var = sizeof(*extern_int8_ptr); // expected-error {{invalid application of 'sizeof' to sizeless type 'svint8_t'}}
26 int sizeof_int8_var_ptr = sizeof(extern_int8_ptr);
27
28 #if __cplusplus >= 201103L
29 int alignof_int8 = alignof(svint8_t); // expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}}
30 int alignof_int8_var = alignof(*extern_int8_ptr); // expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}} expected-warning {{GNU extension}}
31 int alignof_int8_var_ptr = alignof(extern_int8_ptr); // expected-warning {{GNU extension}}
32 #else
33 int alignof_int8 = _Alignof(svint8_t); // expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}}
34 int alignof_int8_var = _Alignof(*extern_int8_ptr); // expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}} expected-warning {{GNU extension}}
35 int alignof_int8_var_ptr = _Alignof(extern_int8_ptr); // expected-warning {{GNU extension}}
36 #endif
37
38 void pass_int8(svint8_t); // expected-note {{no known conversion}}
39
40 svint8_t return_int8();
41
42 typedef svint8_t vec_int8_a __attribute__((vector_size(64))); // expected-error {{invalid vector element type}}
43 typedef svint8_t vec_int8_b __attribute__((ext_vector_type(4))); // expected-error {{invalid vector element type}}
44
45 void dump(const volatile void *);
46
47 void overf(svint8_t);
48 void overf(svint16_t);
49
50 void overf8(svint8_t); // expected-note + {{not viable}}
51 void overf8(int); // expected-note + {{not viable}}
52
53 void overf16(svint16_t); // expected-note + {{not viable}}
54 void overf16(int); // expected-note + {{not viable}}
55
56 void varargs(int, ...);
57
unused()58 void unused() {
59 svint8_t unused_int8; // expected-warning {{unused}}
60 }
61
62 struct incomplete_struct *incomplete_ptr;
63
64 typedef svint8_t sizeless_array[1]; // expected-error {{array has sizeless element type}}
65
func(int sel)66 void func(int sel) {
67 static svint8_t static_int8; // expected-error {{non-local variable with sizeless type 'svint8_t'}}
68
69 svint8_t local_int8;
70 svint16_t local_int16;
71
72 svint8_t __attribute__((aligned)) aligned_int8_1; // expected-error {{'aligned' attribute cannot be applied to sizeless type 'svint8_t'}}
73 svint8_t __attribute__((aligned(4))) aligned_int8_2; // expected-error {{'aligned' attribute cannot be applied to sizeless type 'svint8_t'}}
74 svint8_t _Alignas(int) aligned_int8_3; // expected-error {{'_Alignas' attribute cannot be applied to sizeless type 'svint8_t'}}
75
76 int _Alignas(svint8_t) aligned_int; // expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}}
77
78 // Using pointers to sizeless data isn't wrong here, but because the
79 // type is incomplete, it doesn't provide any alignment guarantees.
80 _Static_assert(__atomic_is_lock_free(1, &local_int8) == __atomic_is_lock_free(1, incomplete_ptr), "");
81 _Static_assert(__atomic_is_lock_free(2, &local_int8) == __atomic_is_lock_free(2, incomplete_ptr), ""); // expected-error {{static_assert expression is not an integral constant expression}}
82 _Static_assert(__atomic_always_lock_free(1, &local_int8) == __atomic_always_lock_free(1, incomplete_ptr), "");
83
84 local_int8; // expected-warning {{expression result unused}}
85
86 (void)local_int8;
87
88 local_int8, 0; // expected-warning + {{expression result unused}}
89
90 0, local_int8; // expected-warning + {{expression result unused}}
91
92 svint8_t init_int8 = local_int8;
93 svint8_t bad_init_int8 = for; // expected-error {{expected expression}}
94
95 #if __cplusplus >= 201103L
96 int empty_brace_init_int = {};
97 svint8_t empty_brace_init_int8 = {};
98 #else
99 int empty_brace_init_int = {}; // expected-error {{scalar initializer cannot be empty}}
100 svint8_t empty_brace_init_int8 = {}; // expected-error {{initializer for sizeless type 'svint8_t' (aka '__SVInt8_t') cannot be empty}}
101 #endif
102 svint8_t brace_init_int8 = {local_int8};
103 svint8_t bad_brace_init_int8_1 = {local_int8, 0}; // expected-error {{excess elements in initializer for indivisible sizeless type 'svint8_t'}}
104 svint8_t bad_brace_init_int8_2 = {0}; // expected-error {{rvalue of type 'int'}}
105 svint8_t bad_brace_init_int8_3 = {local_int16}; // expected-error {{lvalue of type 'svint16_t'}}
106 svint8_t bad_brace_init_int8_4 = {[0] = local_int8}; // expected-error {{designator in initializer for indivisible sizeless type 'svint8_t'}} expected-warning {{array designators are a C99 extension}}
107 svint8_t bad_brace_init_int8_5 = {{local_int8}}; // expected-warning {{too many braces around initializer}}
108 svint8_t bad_brace_init_int8_6 = {{local_int8, 0}}; // expected-warning {{too many braces around initializer}}
109
110 const svint8_t const_int8 = local_int8; // expected-note {{declared const here}}
111 const svint8_t uninit_const_int8; // expected-error {{default initialization of an object of const type 'const svint8_t'}}
112
113 volatile svint8_t volatile_int8;
114
115 const volatile svint8_t const_volatile_int8 = local_int8; // expected-note {{declared const here}}
116 const volatile svint8_t uninit_const_volatile_int8; // expected-error {{default initialization of an object of const type 'const volatile svint8_t'}}
117
118 _Atomic svint8_t atomic_int8; // expected-error {{_Atomic cannot be applied to sizeless type 'svint8_t'}}
119 __restrict svint8_t restrict_int8; // expected-error {{requires a pointer or reference}}
120
121 svint8_t array_int8[1]; // expected-error {{array has sizeless element type}}
122 svint8_t array_int8_init[] = {}; // expected-error {{array has sizeless element type}}
123
124 bool test_int8 = init_int8; // expected-error {{cannot initialize a variable of type 'bool' with an lvalue of type 'svint8_t'}}
125
126 int int_int8 = init_int8; // expected-error {{cannot initialize a variable of type 'int' with an lvalue of type 'svint8_t'}}
127
128 init_int8 = local_int8;
129 init_int8 = local_int16; // expected-error {{assigning to 'svint8_t' (aka '__SVInt8_t') from incompatible type 'svint16_t'}}
130 init_int8 = sel; // expected-error {{assigning to 'svint8_t' (aka '__SVInt8_t') from incompatible type 'int'}}
131
132 sel = local_int8; // expected-error {{assigning to 'int' from incompatible type 'svint8_t'}}
133
134 local_int8 = (svint8_t)local_int8;
135 local_int8 = (const svint8_t)local_int8;
136 local_int8 = (svint8_t)local_int16; // expected-error {{C-style cast from 'svint16_t' (aka '__SVInt16_t') to 'svint8_t' (aka '__SVInt8_t') is not allowed}}
137 local_int8 = (svint8_t)0; // expected-error {{C-style cast from 'int' to 'svint8_t' (aka '__SVInt8_t') is not allowed}}
138 sel = (int)local_int8; // expected-error {{C-style cast from 'svint8_t' (aka '__SVInt8_t') to 'int' is not allowed}}
139
140 init_int8 = local_int8;
141 init_int8 = const_int8;
142 init_int8 = volatile_int8;
143 init_int8 = const_volatile_int8;
144
145 const_int8 = local_int8; // expected-error {{cannot assign to variable 'const_int8' with const-qualified type 'const svint8_t'}}
146
147 volatile_int8 = local_int8;
148 volatile_int8 = const_int8;
149 volatile_int8 = volatile_int8;
150 volatile_int8 = const_volatile_int8;
151
152 const_volatile_int8 = local_int8; // expected-error {{cannot assign to variable 'const_volatile_int8' with const-qualified type 'const volatile svint8_t'}}
153
154 init_int8 = sel ? init_int8 : local_int8;
155 init_int8 = sel ? init_int8 : const_int8;
156 init_int8 = sel ? volatile_int8 : const_int8;
157 init_int8 = sel ? volatile_int8 : const_volatile_int8;
158
159 pass_int8(local_int8);
160 pass_int8(local_int16); // expected-error {{no matching function}}
161
162 local_int8 = return_int8();
163 local_int16 = return_int8(); // expected-error {{assigning to 'svint16_t' (aka '__SVInt16_t') from incompatible type 'svint8_t'}}
164
165 dump(&local_int8);
166 dump(&const_int8);
167 dump(&volatile_int8);
168 dump(&const_volatile_int8);
169
170 dump(&local_int8 + 1); // expected-error {{arithmetic on a pointer to sizeless type}}
171
172 *&local_int8 = local_int8;
173 *&const_int8 = local_int8; // expected-error {{read-only variable is not assignable}}
174 *&volatile_int8 = local_int8;
175 *&const_volatile_int8 = local_int8; // expected-error {{read-only variable is not assignable}}
176
177 global_int8_ptr[0] = local_int8; // expected-error {{subscript of pointer to sizeless type 'svint8_t'}}
178 global_int8_ptr[1] = local_int8; // expected-error {{subscript of pointer to sizeless type 'svint8_t'}}
179 global_int8_ptr = &global_int8_ptr[2]; // expected-error {{subscript of pointer to sizeless type 'svint8_t'}}
180
181 overf(local_int8);
182 overf(local_int16);
183
184 overf8(local_int8);
185 overf8(local_int16); // expected-error {{no matching function}}
186
187 overf16(local_int8); // expected-error {{no matching function}}
188 overf16(local_int16);
189
190 varargs(1, local_int8, local_int16);
191
192 global_int8_ptr++; // expected-error {{arithmetic on a pointer to sizeless type}}
193 global_int8_ptr--; // expected-error {{arithmetic on a pointer to sizeless type}}
194 ++global_int8_ptr; // expected-error {{arithmetic on a pointer to sizeless type}}
195 --global_int8_ptr; // expected-error {{arithmetic on a pointer to sizeless type}}
196 global_int8_ptr + 1; // expected-error {{arithmetic on a pointer to sizeless type}}
197 global_int8_ptr - 1; // expected-error {{arithmetic on a pointer to sizeless type}}
198 global_int8_ptr += 1; // expected-error {{arithmetic on a pointer to sizeless type}}
199 global_int8_ptr -= 1; // expected-error {{arithmetic on a pointer to sizeless type}}
200 global_int8_ptr - global_int8_ptr; // expected-error {{arithmetic on a pointer to sizeless type}}
201
202 +init_int8; // expected-error {{invalid argument type 'svint8_t'}}
203 ++init_int8; // expected-error {{cannot increment value of type 'svint8_t'}}
204 init_int8++; // expected-error {{cannot increment value of type 'svint8_t'}}
205 -init_int8; // expected-error {{invalid argument type 'svint8_t'}}
206 --init_int8; // expected-error {{cannot decrement value of type 'svint8_t'}}
207 init_int8--; // expected-error {{cannot decrement value of type 'svint8_t'}}
208 ~init_int8; // expected-error {{invalid argument type 'svint8_t'}}
209 !init_int8; // expected-error {{invalid argument type 'svint8_t'}}
210 *init_int8; // expected-error {{indirection requires pointer operand}}
211 __real init_int8; // expected-error {{invalid type 'svint8_t'}}
212 __imag init_int8; // expected-error {{invalid type 'svint8_t'}}
213
214 local_int8 + init_int8; // expected-error {{invalid operands to binary expression}}
215 local_int8 - init_int8; // expected-error {{invalid operands to binary expression}}
216 local_int8 *init_int8; // expected-error {{invalid operands to binary expression}}
217 local_int8 / init_int8; // expected-error {{invalid operands to binary expression}}
218 local_int8 % init_int8; // expected-error {{invalid operands to binary expression}}
219 local_int8 &init_int8; // expected-error {{invalid operands to binary expression}}
220 local_int8 | init_int8; // expected-error {{invalid operands to binary expression}}
221 local_int8 ^ init_int8; // expected-error {{invalid operands to binary expression}}
222 local_int8 << init_int8; // expected-error {{invalid operands to binary expression}}
223 local_int8 >> init_int8; // expected-error {{invalid operands to binary expression}}
224 local_int8 < init_int8; // expected-error {{invalid operands to binary expression}}
225 local_int8 <= init_int8; // expected-error {{invalid operands to binary expression}}
226 local_int8 == init_int8; // expected-error {{invalid operands to binary expression}}
227 local_int8 != init_int8; // expected-error {{invalid operands to binary expression}}
228 local_int8 >= init_int8; // expected-error {{invalid operands to binary expression}}
229 local_int8 > init_int8; // expected-error {{invalid operands to binary expression}}
230 local_int8 &&init_int8; // expected-error {{invalid operands to binary expression}} expected-error {{not contextually convertible}}
231 local_int8 || init_int8; // expected-error {{invalid operands to binary expression}} expected-error {{not contextually convertible}}
232
233 local_int8 += init_int8; // expected-error {{invalid operands to binary expression}}
234 local_int8 -= init_int8; // expected-error {{invalid operands to binary expression}}
235 local_int8 *= init_int8; // expected-error {{invalid operands to binary expression}}
236 local_int8 /= init_int8; // expected-error {{invalid operands to binary expression}}
237 local_int8 %= init_int8; // expected-error {{invalid operands to binary expression}}
238 local_int8 &= init_int8; // expected-error {{invalid operands to binary expression}}
239 local_int8 |= init_int8; // expected-error {{invalid operands to binary expression}}
240 local_int8 ^= init_int8; // expected-error {{invalid operands to binary expression}}
241 local_int8 <<= init_int8; // expected-error {{invalid operands to binary expression}}
242 local_int8 >>= init_int8; // expected-error {{invalid operands to binary expression}}
243
244 local_int8 + 0; // expected-error {{invalid operands to binary expression}}
245 local_int8 - 0; // expected-error {{invalid operands to binary expression}}
246 local_int8 * 0; // expected-error {{invalid operands to binary expression}}
247 local_int8 / 0; // expected-error {{invalid operands to binary expression}}
248 local_int8 % 0; // expected-error {{invalid operands to binary expression}}
249 local_int8 & 0; // expected-error {{invalid operands to binary expression}}
250 local_int8 | 0; // expected-error {{invalid operands to binary expression}}
251 local_int8 ^ 0; // expected-error {{invalid operands to binary expression}}
252 local_int8 << 0; // expected-error {{invalid operands to binary expression}}
253 local_int8 >> 0; // expected-error {{invalid operands to binary expression}}
254 local_int8 < 0; // expected-error {{invalid operands to binary expression}}
255 local_int8 <= 0; // expected-error {{invalid operands to binary expression}}
256 local_int8 == 0; // expected-error {{invalid operands to binary expression}}
257 local_int8 != 0; // expected-error {{invalid operands to binary expression}}
258 local_int8 >= 0; // expected-error {{invalid operands to binary expression}}
259 local_int8 > 0; // expected-error {{invalid operands to binary expression}}
260 local_int8 && 0; // expected-error {{invalid operands to binary expression}} expected-error {{not contextually convertible}}
261 local_int8 || 0; // expected-error {{invalid operands to binary expression}} expected-error {{not contextually convertible}}
262
263 if (local_int8) { // expected-error {{not contextually convertible to 'bool'}}
264 }
265 while (local_int8) { // expected-error {{not contextually convertible to 'bool'}}
266 }
267 do {
268 } while (local_int8); // expected-error {{not contextually convertible to 'bool'}}
269 switch (local_int8) { // expected-error {{statement requires expression of integer type}}
270 default:;
271 }
272 }
273
vararg_receiver(int count,svint8_t first,...)274 int vararg_receiver(int count, svint8_t first, ...) {
275 __builtin_va_list va;
276
277 __builtin_va_start(va, first);
278 __builtin_va_arg(va, svint8_t);
279 __builtin_va_end(va);
280 return count;
281 }
282
283 struct sized_struct {
284 int f1;
285 svint8_t f2; // expected-error {{field has sizeless type 'svint8_t'}}
286 svint8_t f3 : 2; // expected-error {{field has sizeless type 'svint8_t'}}
287 svint8_t : 3; // expected-error {{field has sizeless type 'svint8_t'}}
288 };
289
290 union sized_union {
291 int f1;
292 svint8_t f2; // expected-error {{field has sizeless type 'svint8_t'}}
293 svint8_t f3 : 2; // expected-error {{field has sizeless type 'svint8_t'}}
294 svint8_t : 3; // expected-error {{field has sizeless type 'svint8_t'}}
295 };
296
297 void pass_int8_ref(svint8_t &); // expected-note {{not viable}}
298
299 svint8_t &return_int8_ref();
300 #if __cplusplus >= 201103L
301 svint8_t &&return_int8_rvalue_ref();
302 #endif
303
304 template <typename T>
305 struct s_template {
306 T y; // expected-error {{field has sizeless type '__SVInt8_t'}}
307 };
308
309 template <typename T>
310 struct s_ptr_template {
311 s_ptr_template();
312 s_ptr_template(T, svint8_t = svint8_t());
313 s_ptr_template(const s_ptr_template &, svint8_t = svint8_t());
314 T *y;
315 };
316
317 template <typename T>
318 struct s_array_template {
319 T y[1]; // expected-error {{array has sizeless element type}}
320 };
321
322 struct widget {
323 widget(s_ptr_template<int>);
324 svint8_t operator[](int);
325 };
326
327 template <typename T>
328 struct wrapper_iterator {
329 T operator++();
330 T operator*() const;
331 bool operator!=(const wrapper_iterator &) const;
332 };
333
334 template <typename T>
335 struct wrapper {
336 wrapper();
337 operator T() const;
338 wrapper_iterator<T> begin() const;
339 wrapper_iterator<T> end() const;
340 };
341
342 #if __cplusplus >= 201103L
343 struct explicit_conv {
344 explicit operator svint8_t() const; // expected-note {{explicit conversion function is not a candidate}}
345 };
346 #endif
347
348 struct constructible_from_sizeless {
349 constructible_from_sizeless(svint8_t);
350 };
351
352 void with_default(svint8_t = svint8_t());
353
354 #if __cplusplus >= 201103L
ce_taking_int8(svint8_t)355 constexpr int ce_taking_int8(svint8_t) { return 1; } // expected-error {{constexpr function's 1st parameter type 'svint8_t' (aka '__SVInt8_t') is not a literal type}}
356 #endif
357
358 #if __cplusplus < 201703L
359 void throwing_func() throw(svint8_t); // expected-error {{sizeless type 'svint8_t' (aka '__SVInt8_t') is not allowed in exception specification}}
360 void throwing_pointer_func() throw(svint8_t *);
361 void throwing_reference_func() throw(svint8_t &); // expected-error {{reference to sizeless type 'svint8_t' (aka '__SVInt8_t') is not allowed in exception specification}}
362 #endif
363
364 template <typename T>
template_fn_direct(T)365 void template_fn_direct(T) {}
366 template <typename T>
template_fn_ref(T &)367 void template_fn_ref(T &) {}
368 template <typename T>
template_fn_const_ref(const T &)369 void template_fn_const_ref(const T &) {}
370 #if __cplusplus >= 201103L
371 template <typename T>
template_fn_rvalue_ref(T &&)372 void template_fn_rvalue_ref(T &&) {}
373 #endif
374
375 #if __cplusplus >= 201103L
376 template <typename T>
377 using array_alias = T[1]; // expected-error {{array has sizeless element type '__SVInt8_t'}}
378 extern array_alias<int> *array_alias_int_ptr;
379 extern array_alias<svint8_t> *array_alias_int8_ptr; // expected-note {{in instantiation of template type alias 'array_alias' requested here}}
380 #endif
381
382 extern "C" svint8_t c_return_int8();
383
cxx_only(int sel)384 void cxx_only(int sel) {
385 svint8_t local_int8;
386 svint16_t local_int16;
387
388 pass_int8_ref(local_int8);
389 pass_int8_ref(local_int16); // expected-error {{no matching function}}
390
391 local_int8 = return_int8_ref();
392 local_int16 = return_int8_ref(); // expected-error {{assigning to 'svint16_t' (aka '__SVInt16_t') from incompatible type 'svint8_t'}}
393 return_int8_ref() = local_int8;
394 return_int8_ref() = local_int16; // expected-error {{assigning to 'svint8_t' (aka '__SVInt8_t') from incompatible type 'svint16_t'}}
395
396 #if __cplusplus >= 201103L
397 local_int8 = return_int8_rvalue_ref();
398 local_int16 = return_int8_rvalue_ref(); // expected-error {{assigning to 'svint16_t' (aka '__SVInt16_t') from incompatible type 'svint8_t'}}
399
400 return_int8_rvalue_ref() = local_int8; // expected-error {{expression is not assignable}}
401 return_int8_rvalue_ref() = local_int16; // expected-error {{expression is not assignable}}
402 #endif
403
404 local_int8 = static_cast<svint8_t>(local_int8);
405 local_int8 = static_cast<svint8_t>(local_int16); // expected-error {{static_cast from 'svint16_t' (aka '__SVInt16_t') to 'svint8_t' (aka '__SVInt8_t') is not allowed}}
406 local_int8 = static_cast<svint8_t>(0); // expected-error {{static_cast from 'int' to 'svint8_t' (aka '__SVInt8_t') is not allowed}}
407 local_int16 = static_cast<svint16_t>(local_int8); // expected-error {{static_cast from 'svint8_t' (aka '__SVInt8_t') to 'svint16_t' (aka '__SVInt16_t') is not allowed}}
408 sel = static_cast<int>(local_int8); // expected-error {{static_cast from 'svint8_t' (aka '__SVInt8_t') to 'int' is not allowed}}
409
410 throw local_int8; // expected-error {{cannot throw object of sizeless type 'svint8_t'}}
411 throw global_int8_ptr;
412
413 try {
414 } catch (int) {
415 }
416 try {
417 } catch (svint8_t) { // expected-error {{cannot catch sizeless type 'svint8_t'}}
418 }
419 try {
420 } catch (svint8_t *) {
421 }
422 try {
423 } catch (svint8_t &) { // expected-error {{cannot catch reference to sizeless type 'svint8_t'}}
424 }
425
426 new svint8_t; // expected-error {{allocation of sizeless type 'svint8_t'}}
427 new svint8_t(); // expected-error {{allocation of sizeless type 'svint8_t'}}
428 new svint8_t[10]; // expected-error {{allocation of sizeless type 'svint8_t'}}
429 new svint8_t *;
430
431 new (global_int8_ptr) svint8_t; // expected-error {{allocation of sizeless type 'svint8_t'}}
432 new (global_int8_ptr) svint8_t(); // expected-error {{allocation of sizeless type 'svint8_t'}}
433 new (global_int8_ptr) svint8_t[10]; // expected-error {{allocation of sizeless type 'svint8_t'}}
434
435 delete global_int8_ptr; // expected-error {{cannot delete expression of type 'svint8_t *'}}
436 delete[] global_int8_ptr; // expected-error {{cannot delete expression of type 'svint8_t *'}}
437
438 local_int8.~__SVInt8_t(); // expected-error {{object expression of non-scalar type 'svint8_t' (aka '__SVInt8_t') cannot be used in a pseudo-destructor expression}}
439
440 (void)svint8_t();
441
442 local_int8 = svint8_t();
443 local_int8 = svint16_t(); // expected-error {{assigning to 'svint8_t' (aka '__SVInt8_t') from incompatible type 'svint16_t'}}
444
445 s_template<int> st_int;
446 s_template<svint8_t> st_svint8; // expected-note {{in instantiation}}
447
448 s_ptr_template<int> st_ptr_int;
449 s_ptr_template<svint8_t> st_ptr_svint8;
450
451 widget w(1);
452 local_int8 = w[1];
453
454 s_array_template<int> st_array_int;
455 s_array_template<svint8_t> st_array_svint8; // expected-note {{in instantiation}}
456
457 local_int8 = static_cast<svint8_t>(wrapper<svint8_t>());
458 local_int16 = static_cast<svint8_t>(wrapper<svint8_t>()); // expected-error {{assigning to 'svint16_t' (aka '__SVInt16_t') from incompatible type 'svint8_t'}}
459
460 local_int8 = wrapper<svint8_t>();
461 local_int16 = wrapper<svint8_t>(); // expected-error {{assigning to 'svint16_t' (aka '__SVInt16_t') from incompatible type 'wrapper<svint8_t>'}}
462
463 svint8_t &ref_int8 = local_int8;
464 ref_int8 = ref_int8; // expected-warning {{explicitly assigning value of variable of type 'svint8_t' (aka '__SVInt8_t') to itself}}
465 ref_int8 = local_int8;
466 local_int8 = ref_int8;
467
468 #if __cplusplus >= 201103L
469 svint8_t zero_init_int8{};
470 svint8_t init_int8{local_int8};
471 svint8_t bad_brace_init_int8_1{local_int8, 0}; // expected-error {{excess elements in initializer for indivisible sizeless type 'svint8_t'}}
472 svint8_t bad_brace_init_int8_2{0}; // expected-error {{rvalue of type 'int'}}
473 svint8_t bad_brace_init_int8_3{local_int16}; // expected-error {{lvalue of type 'svint16_t'}}
474 svint8_t bad_brace_init_int8_4{[0] = local_int8}; // expected-error {{designator in initializer for indivisible sizeless type 'svint8_t'}} expected-warning {{array designators are a C99 extension}}
475 svint8_t bad_brace_init_int8_5{{local_int8}}; // expected-warning {{too many braces around initializer}}
476 svint8_t bad_brace_init_int8_6{{local_int8, 0}}; // expected-warning {{too many braces around initializer}}
477 svint8_t wrapper_init_int8{wrapper<svint8_t>()};
478 svint8_t &ref_init_int8{local_int8};
479
480 template_fn_direct<svint8_t>({wrapper<svint8_t>()});
481 #endif
482
483 template_fn_direct(local_int8);
484 template_fn_ref(local_int8);
485 template_fn_const_ref(local_int8);
486 #if __cplusplus >= 201103L
487 template_fn_rvalue_ref(local_int8);
488 #endif
489
490 #if __cplusplus >= 201103L
491 constexpr svint8_t ce_int8_a = wrapper<svint8_t>(); // expected-error {{constexpr variable cannot have non-literal type 'const svint8_t'}}
492 #endif
493
494 (void)typeid(__SVInt8_t);
495 (void)typeid(__SVInt8_t *);
496 (void)typeid(local_int8);
497 (void)typeid(ref_int8);
498 (void)typeid(static_int8_ptr);
499
500 _Static_assert(__is_trivially_copyable(svint8_t), "");
501 _Static_assert(__is_trivially_destructible(svint8_t), "");
502 _Static_assert(!__is_nothrow_assignable(svint8_t, svint8_t), "");
503 _Static_assert(__is_nothrow_assignable(svint8_t &, svint8_t), "");
504 _Static_assert(!__is_nothrow_assignable(svint8_t &, svint16_t), "");
505 _Static_assert(__is_constructible(svint8_t), "");
506 _Static_assert(__is_constructible(svint8_t, svint8_t), "");
507 _Static_assert(!__is_constructible(svint8_t, svint8_t, svint8_t), "");
508 _Static_assert(!__is_constructible(svint8_t, svint16_t), "");
509 _Static_assert(__is_nothrow_constructible(svint8_t), "");
510 _Static_assert(__is_nothrow_constructible(svint8_t, svint8_t), "");
511 _Static_assert(!__is_nothrow_constructible(svint8_t, svint16_t), "");
512 _Static_assert(!__is_assignable(svint8_t, svint8_t), "");
513 _Static_assert(__is_assignable(svint8_t &, svint8_t), "");
514 _Static_assert(!__is_assignable(svint8_t &, svint16_t), "");
515 _Static_assert(__has_nothrow_assign(svint8_t), "");
516 _Static_assert(__has_nothrow_move_assign(svint8_t), "");
517 _Static_assert(__has_nothrow_copy(svint8_t), "");
518 _Static_assert(__has_nothrow_constructor(svint8_t), "");
519 _Static_assert(__has_trivial_assign(svint8_t), "");
520 _Static_assert(__has_trivial_move_assign(svint8_t), "");
521 _Static_assert(__has_trivial_copy(svint8_t), "");
522 _Static_assert(__has_trivial_constructor(svint8_t), "");
523 _Static_assert(__has_trivial_move_constructor(svint8_t), "");
524 _Static_assert(__has_trivial_destructor(svint8_t), "");
525 _Static_assert(!__has_virtual_destructor(svint8_t), "");
526 _Static_assert(!__is_abstract(svint8_t), "");
527 _Static_assert(!__is_aggregate(svint8_t), "");
528 _Static_assert(!__is_base_of(svint8_t, svint8_t), "");
529 _Static_assert(!__is_class(svint8_t), "");
530 _Static_assert(__is_convertible_to(svint8_t, svint8_t), "");
531 _Static_assert(!__is_convertible_to(svint8_t, svint16_t), "");
532 _Static_assert(!__is_empty(svint8_t), "");
533 _Static_assert(!__is_enum(svint8_t), "");
534 _Static_assert(!__is_final(svint8_t), "");
535 _Static_assert(!__is_literal(svint8_t), "");
536 _Static_assert(__is_pod(svint8_t), "");
537 _Static_assert(!__is_polymorphic(svint8_t), "");
538 _Static_assert(__is_trivial(svint8_t), "");
539 _Static_assert(__is_object(svint8_t), "");
540 _Static_assert(!__is_arithmetic(svint8_t), "");
541 _Static_assert(!__is_floating_point(svint8_t), "");
542 _Static_assert(!__is_integral(svint8_t), "");
543 _Static_assert(!__is_void(svint8_t), "");
544 _Static_assert(!__is_array(svint8_t), "");
545 _Static_assert(!__is_function(svint8_t), "");
546 _Static_assert(!__is_reference(svint8_t), "");
547 _Static_assert(__is_reference(svint8_t &), "");
548 _Static_assert(__is_reference(const svint8_t &), "");
549 _Static_assert(!__is_lvalue_reference(svint8_t), "");
550 _Static_assert(__is_lvalue_reference(svint8_t &), "");
551 #if __cplusplus >= 201103L
552 _Static_assert(!__is_lvalue_reference(svint8_t &&), "");
553 #endif
554 _Static_assert(!__is_rvalue_reference(svint8_t), "");
555 _Static_assert(!__is_rvalue_reference(svint8_t &), "");
556 #if __cplusplus >= 201103L
557 _Static_assert(__is_rvalue_reference(svint8_t &&), "");
558 #endif
559 _Static_assert(!__is_fundamental(svint8_t), "");
560 _Static_assert(__is_object(svint8_t), "");
561 _Static_assert(!__is_scalar(svint8_t), "");
562 _Static_assert(!__is_compound(svint8_t), "");
563 _Static_assert(!__is_pointer(svint8_t), "");
564 _Static_assert(__is_pointer(svint8_t *), "");
565 _Static_assert(!__is_member_object_pointer(svint8_t), "");
566 _Static_assert(!__is_member_function_pointer(svint8_t), "");
567 _Static_assert(!__is_member_pointer(svint8_t), "");
568 _Static_assert(!__is_const(svint8_t), "");
569 _Static_assert(__is_const(const svint8_t), "");
570 _Static_assert(__is_const(const volatile svint8_t), "");
571 _Static_assert(!__is_volatile(svint8_t), "");
572 _Static_assert(__is_volatile(volatile svint8_t), "");
573 _Static_assert(__is_volatile(const volatile svint8_t), "");
574 _Static_assert(!__is_standard_layout(svint8_t), "");
575 // At present these types are opaque and don't have the properties
576 // implied by their name.
577 _Static_assert(!__is_signed(svint8_t), "");
578 _Static_assert(!__is_unsigned(svint8_t), "");
579
580 #if __cplusplus >= 201103L
581 auto auto_int8 = local_int8;
582 auto auto_int16 = local_int16;
583 #if __cplusplus >= 201703L
584 auto [auto_int8_a] = local_int8; // expected-error {{cannot decompose non-class, non-array type '__SVInt8_t'}}
585 #endif
586 #endif
587
588 s_ptr_template<int> y;
589 s_ptr_template<int> &x = y;
590
591 constructible_from_sizeless cfs1(local_int8);
592 constructible_from_sizeless cfs2 = local_int8;
593 #if __cplusplus >= 201103L
594 constructible_from_sizeless cfs3{local_int8};
595 #endif
596
597 #if __cplusplus >= 201103L
598 local_int8 = ([]() { return svint8_t(); })();
599 local_int8 = ([]() -> svint8_t { return svint8_t(); })();
600 auto fn1 = [&local_int8](svint8_t x) { local_int8 = x; };
601 auto fn2 = [&local_int8](svint8_t *ptr) { *ptr = local_int8; };
602 #if __cplusplus >= 201703L
603 auto fn3 = [a(return_int8())] {}; // expected-error {{field has sizeless type '__SVInt8_t'}}
604 #endif
605 auto fn4 = [local_int8](svint8_t *ptr) { *ptr = local_int8; }; // expected-error {{by-copy capture of variable 'local_int8' with sizeless type 'svint8_t'}}
606
607 for (auto x : local_int8) { // expected-error {{no viable 'begin' function available}}
608 }
609 for (auto x : wrapper<svint8_t>()) {
610 (void)x;
611 }
612 for (const svint8_t &x : wrapper<svint8_t>()) { // expected-warning {{loop variable 'x' binds to a temporary value produced by a range of type 'wrapper<svint8_t>'}} expected-note {{use non-reference type}}
613 (void)x;
614 }
615 for (const svint8_t x : wrapper<const svint8_t &>()) {
616 (void)x;
617 }
618 #endif
619 }
620
621 #if __cplusplus >= 201103L
ret_bad_conv()622 svint8_t ret_bad_conv() { return explicit_conv(); } // expected-error {{no viable conversion from returned value of type 'explicit_conv' to function return type 'svint8_t'}}
623
624 #pragma clang diagnostic warning "-Wc++98-compat"
625
incompat_init()626 void incompat_init() { __attribute__((unused)) svint8_t foo = {}; } // expected-warning {{initializing 'svint8_t' (aka '__SVInt8_t') from an empty initializer list is incompatible with C++98}}
627
628 #endif
629