1 // RUN: %clang_cc1 -fsyntax-only -verify -Wall -W -Wno-comment -Wno-strict-prototypes -triple arm64-linux-gnu -target-feature +sve -std=c90 %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -Wall -W -Wno-strict-prototypes -triple arm64-linux-gnu -target-feature +sve -std=c11 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify -Wall -W -Wno-strict-prototypes -triple arm64-linux-gnu -target-feature +sve -std=gnu11 %s
5 typedef __SVInt8_t svint8_t
;
6 typedef __SVInt16_t svint16_t
;
8 svint8_t global_int8
; // expected-error {{non-local variable with sizeless type 'svint8_t'}}
9 extern svint8_t extern_int8
; // expected-error {{non-local variable with sizeless type 'svint8_t'}}
10 static svint8_t static_int8
; // expected-error {{non-local variable with sizeless type 'svint8_t'}}
11 __thread svint8_t thread_int8
; // expected-error {{non-local variable with sizeless type 'svint8_t'}}
12 svint8_t
*global_int8_ptr
;
13 extern svint8_t
*extern_int8_ptr
;
14 static svint8_t
*static_int8_ptr
;
16 typedef svint8_t int8_typedef
;
17 typedef svint8_t
*int8_ptr_typedef
;
19 int sizeof_int8
= sizeof(svint8_t
); // expected-error {{invalid application of 'sizeof' to sizeless type 'svint8_t'}}
20 int sizeof_int8_var
= sizeof(*extern_int8_ptr
); // expected-error {{invalid application of 'sizeof' to sizeless type 'svint8_t'}}
21 int sizeof_int8_var_ptr
= sizeof(extern_int8_ptr
);
23 int alignof_int8
= _Alignof(svint8_t
); // expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}}
24 int alignof_int8_var
= _Alignof(*extern_int8_ptr
); // expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}} expected-warning {{GNU extension}}
25 int alignof_int8_var_ptr
= _Alignof(extern_int8_ptr
); // expected-warning {{GNU extension}}
27 void pass_int8(svint8_t
); // expected-note {{passing argument to parameter here}}
29 svint8_t
return_int8(void);
31 typedef svint8_t vec_int8_a
__attribute__((vector_size(64))); // expected-error {{invalid vector element type}}
32 typedef svint8_t vec_int8_b
__attribute__((ext_vector_type(4))); // expected-error {{invalid vector element type}}
34 void dump(const volatile void *);
36 void __attribute__((overloadable
)) overf(svint8_t
);
37 void __attribute__((overloadable
)) overf(svint16_t
);
39 void __attribute__((overloadable
)) overf8(svint8_t
); // expected-note + {{not viable}}
40 void __attribute__((overloadable
)) overf8(int); // expected-note + {{not viable}}
42 void __attribute__((overloadable
)) overf16(svint16_t
); // expected-note + {{not viable}}
43 void __attribute__((overloadable
)) overf16(int); // expected-note + {{not viable}}
46 void varargs(int, ...);
49 svint8_t unused_int8
; // expected-warning {{unused}}
52 struct incomplete_struct
*incomplete_ptr
;
54 typedef svint8_t sizeless_array
[1]; // expected-error {{array has sizeless element type}}
57 static svint8_t static_int8
; // expected-error {{non-local variable with sizeless type 'svint8_t'}}
60 int8_typedef typedef_int8
;
61 svint16_t local_int16
;
63 svint8_t
__attribute__((aligned
)) aligned_int8_1
; // expected-error {{'aligned' attribute cannot be applied to sizeless type 'svint8_t'}}
64 svint8_t
__attribute__((aligned(4))) aligned_int8_2
; // expected-error {{'aligned' attribute cannot be applied to sizeless type 'svint8_t'}}
65 svint8_t
_Alignas(int) aligned_int8_3
; // expected-error {{'_Alignas' attribute cannot be applied to sizeless type 'svint8_t'}}
67 int _Alignas(svint8_t
) aligned_int
; // expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}}
69 // Using pointers to sizeless data isn't wrong here, but because the
70 // type is incomplete, it doesn't provide any alignment guarantees.
71 _Static_assert(__atomic_is_lock_free(1, &local_int8
) == __atomic_is_lock_free(1, incomplete_ptr
), "");
72 _Static_assert(__atomic_is_lock_free(2, &local_int8
) == __atomic_is_lock_free(2, incomplete_ptr
), ""); // expected-error {{static assertion expression is not an integral constant expression}}
73 _Static_assert(__atomic_always_lock_free(1, &local_int8
) == __atomic_always_lock_free(1, incomplete_ptr
), "");
75 local_int8
; // expected-warning {{expression result unused}}
79 local_int8
, 0; // expected-warning {{left operand of comma operator has no effect}}
81 0, local_int8
; // expected-warning {{left operand of comma operator has no effect}} expected-warning {{expression result unused}}
83 svint8_t init_int8
= local_int8
;
84 svint8_t bad_init_int8
= for; // expected-error {{expected expression}}
86 int empty_brace_init_int
= {}; // expected-error {{scalar initializer cannot be empty}}
87 svint8_t empty_brace_init_int8
= {}; // expected-error {{initializer for sizeless type 'svint8_t' (aka '__SVInt8_t') cannot be empty}}
88 svint8_t brace_init_int8
= {local_int8
};
89 svint8_t bad_brace_init_int8_1
= {local_int8
, 0}; // expected-warning {{excess elements in initializer for indivisible sizeless type 'svint8_t'}}
90 svint8_t bad_brace_init_int8_2
= {0}; // expected-error {{incompatible type 'int'}}
91 svint8_t bad_brace_init_int8_3
= {local_int16
}; // expected-error {{incompatible type 'svint16_t'}}
92 svint8_t bad_brace_init_int8_4
= {[0] = local_int8
}; // expected-error {{designator in initializer for indivisible sizeless type 'svint8_t'}}
93 svint8_t bad_brace_init_int8_5
= {{local_int8
}}; // expected-warning {{too many braces around initializer}}
94 svint8_t bad_brace_init_int8_6
= {{local_int8
, 0}}; // expected-warning {{too many braces around initializer}}
96 const svint8_t const_int8
= local_int8
; // expected-note {{declared const here}}
97 const svint8_t uninit_const_int8
;
99 volatile svint8_t volatile_int8
;
101 const volatile svint8_t const_volatile_int8
= local_int8
; // expected-note {{declared const here}}
102 const volatile svint8_t uninit_const_volatile_int8
;
104 _Atomic svint8_t atomic_int8
; // expected-error {{_Atomic cannot be applied to sizeless type 'svint8_t'}}
105 __restrict svint8_t restrict_int8
; // expected-error {{requires a pointer or reference}}
107 svint8_t array_int8
[1]; // expected-error {{array has sizeless element type}}
108 svint8_t array_int8_init
[] = {}; // expected-error {{array has sizeless element type}}
110 _Bool test_int8
= init_int8
; // expected-error {{initializing '_Bool' with an expression of incompatible type 'svint8_t'}}
112 int int_int8
= init_int8
; // expected-error {{initializing 'int' with an expression of incompatible type 'svint8_t'}}
114 init_int8
= local_int8
;
115 init_int8
= local_int16
; // expected-error {{assigning to 'svint8_t' (aka '__SVInt8_t') from incompatible type 'svint16_t'}}
116 init_int8
= sel
; // expected-error {{assigning to 'svint8_t' (aka '__SVInt8_t') from incompatible type 'int'}}
118 sel
= local_int8
; // expected-error {{assigning to 'int' from incompatible type 'svint8_t'}}
120 local_int8
= (svint8_t
)local_int8
;
121 local_int8
= (const svint8_t
)local_int8
;
122 local_int8
= (svint8_t
)local_int16
; // expected-error {{used type 'svint8_t' (aka '__SVInt8_t') where arithmetic or pointer type is required}}
123 local_int8
= (svint8_t
)0; // expected-error {{used type 'svint8_t' (aka '__SVInt8_t') where arithmetic or pointer type is required}}
124 sel
= (int)local_int8
; // expected-error {{operand of type 'svint8_t' (aka '__SVInt8_t') where arithmetic or pointer type is required}}
126 init_int8
= local_int8
;
127 init_int8
= const_int8
;
128 init_int8
= volatile_int8
;
129 init_int8
= const_volatile_int8
;
131 const_int8
= local_int8
; // expected-error {{cannot assign to variable 'const_int8' with const-qualified type 'const svint8_t'}}
133 volatile_int8
= local_int8
;
134 volatile_int8
= const_int8
;
135 volatile_int8
= volatile_int8
;
136 volatile_int8
= const_volatile_int8
;
138 const_volatile_int8
= local_int8
; // expected-error {{cannot assign to variable 'const_volatile_int8' with const-qualified type 'const volatile svint8_t'}}
140 init_int8
= sel
? init_int8
: local_int8
;
141 init_int8
= sel
? init_int8
: typedef_int8
;
142 init_int8
= sel
? init_int8
: const_int8
;
143 init_int8
= sel
? volatile_int8
: const_int8
;
144 init_int8
= sel
? volatile_int8
: const_volatile_int8
;
146 pass_int8(local_int8
);
147 pass_int8(local_int16
); // expected-error {{passing 'svint16_t' (aka '__SVInt16_t') to parameter of incompatible type 'svint8_t'}}
149 local_int8
= return_int8();
150 local_int16
= return_int8(); // expected-error {{assigning to 'svint16_t' (aka '__SVInt16_t') from incompatible type 'svint8_t'}}
154 dump(&volatile_int8
);
155 dump(&const_volatile_int8
);
157 dump(&local_int8
+ 1); // expected-error {{arithmetic on a pointer to sizeless type}}
159 *&local_int8
= local_int8
;
160 *&const_int8
= local_int8
; // expected-error {{read-only variable is not assignable}}
161 *&volatile_int8
= local_int8
;
162 *&const_volatile_int8
= local_int8
; // expected-error {{read-only variable is not assignable}}
164 global_int8_ptr
[0] = local_int8
; // expected-error {{subscript of pointer to sizeless type 'svint8_t'}}
165 global_int8_ptr
[1] = local_int8
; // expected-error {{subscript of pointer to sizeless type 'svint8_t'}}
166 global_int8_ptr
= &global_int8_ptr
[2]; // expected-error {{subscript of pointer to sizeless type 'svint8_t'}}
172 overf8(local_int16
); // expected-error {{no matching function}}
174 overf16(local_int8
); // expected-error {{no matching function}}
175 overf16(local_int16
);
178 varargs(1, local_int8
, local_int16
);
180 global_int8_ptr
++; // expected-error {{arithmetic on a pointer to sizeless type}}
181 global_int8_ptr
--; // expected-error {{arithmetic on a pointer to sizeless type}}
182 ++global_int8_ptr
; // expected-error {{arithmetic on a pointer to sizeless type}}
183 --global_int8_ptr
; // expected-error {{arithmetic on a pointer to sizeless type}}
184 global_int8_ptr
+ 1; // expected-error {{arithmetic on a pointer to sizeless type}}
185 global_int8_ptr
- 1; // expected-error {{arithmetic on a pointer to sizeless type}}
186 global_int8_ptr
+= 1; // expected-error {{arithmetic on a pointer to sizeless type}}
187 global_int8_ptr
-= 1; // expected-error {{arithmetic on a pointer to sizeless type}}
188 global_int8_ptr
- global_int8_ptr
; // expected-error {{arithmetic on a pointer to sizeless type}}
190 ++init_int8
; // expected-error {{cannot increment value of type 'svint8_t'}}
191 init_int8
++; // expected-error {{cannot increment value of type 'svint8_t'}}
192 --init_int8
; // expected-error {{cannot decrement value of type 'svint8_t'}}
193 init_int8
--; // expected-error {{cannot decrement value of type 'svint8_t'}}
194 !init_int8
; // expected-error {{invalid argument type 'svint8_t'}}
195 *init_int8
; // expected-error {{indirection requires pointer operand}}
196 __real init_int8
; // expected-error {{invalid type 'svint8_t'}}
197 __imag init_int8
; // expected-error {{invalid type 'svint8_t'}}
199 local_int8
&&init_int8
; // expected-error {{invalid operands to binary expression}}
200 local_int8
|| init_int8
; // expected-error {{invalid operands to binary expression}}
202 if (local_int8
) { // expected-error {{statement requires expression of scalar type}}
204 while (local_int8
) { // expected-error {{statement requires expression of scalar type}}
206 do { // expected-error {{statement requires expression of scalar type}}
207 } while (local_int8
);
208 switch (local_int8
) { // expected-error {{statement requires expression of integer type}}
213 int vararg_receiver(int count
, svint8_t first
, ...) {
214 __builtin_va_list va
;
216 __builtin_va_start(va
, first
);
217 __builtin_va_arg(va
, svint8_t
);
218 __builtin_va_end(va
);
222 struct sized_struct
{
224 svint8_t f2
; // expected-error {{field has sizeless type 'svint8_t'}}
225 svint8_t f3
: 2; // expected-error {{field has sizeless type 'svint8_t'}}
226 svint8_t
: 3; // expected-error {{field has sizeless type 'svint8_t'}}
231 svint8_t f2
; // expected-error {{field has sizeless type 'svint8_t'}}
232 svint8_t f3
: 2; // expected-error {{field has sizeless type 'svint8_t'}}
233 svint8_t
: 3; // expected-error {{field has sizeless type 'svint8_t'}}
236 #if __STDC_VERSION__ >= 201112L
237 void test_generic(void) {
239 svint16_t local_int16
;
241 int a1
[_Generic(local_int8
, svint8_t
: 1, svint16_t
: 2, default : 3) == 1 ? 1 : -1];
242 int a2
[_Generic(local_int16
, svint8_t
: 1, svint16_t
: 2, default : 3) == 2 ? 1 : -1];
243 int a3
[_Generic(0, svint8_t
: 1, svint16_t
: 2, default : 3) == 3 ? 1 : -1];
244 (void)_Generic(0, svint8_t
: 1, svint8_t
: 2, default : 3); // expected-error {{type 'svint8_t' (aka '__SVInt8_t') in generic association compatible with previously specified type 'svint8_t'}} expected-note {{compatible type}}
247 void test_compound_literal(void) {
250 (void)(svint8_t
){local_int8
};