Debian Codegraph @

gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-2.c

raw
1 /* { dg-options "-std=gnu99 -msve-vector-bits=256" } */
2
3 #include <arm_sve.h>
4
5 typedef signed char int8x32_t __attribute__((__vector_size__ (32)));
6
7 /* Sizeless objects with global scope. */
8
9 svint8_t global_sve_sc; /* { dg-error {SVE type 'svint8_t' does not have a fixed size} } */
10 static svint8_t local_sve_sc; /* { dg-error {SVE type 'svint8_t' does not have a fixed size} } */
11 extern svint8_t extern_sve_sc; /* { dg-error {SVE type 'svint8_t' does not have a fixed size} } */
12 __thread svint8_t tls_sve_sc; /* { dg-error {variables of type 'svint8_t' cannot have thread-local storage duration} } */
13 _Atomic svint8_t atomic_sve_sc; /* { dg-error {SVE type 'svint8_t' does not have a fixed size} } */
14
15 /* Sizeless arrays. */
16
17 typedef svint8_t array_type[2]; /* { dg-error {array elements cannot have SVE type 'svint8_t'} } */
18 extern svint8_t extern_array[]; /* { dg-error {array elements cannot have SVE type 'svint8_t'} } */
19
20 /* Sizeless fields. */
21
22 struct struct1 {
23 svint8_t a; /* { dg-error {fields cannot have SVE type 'svint8_t'} } */
24 };
25
26 union union1 {
27 svint8_t a; /* { dg-error {fields cannot have SVE type 'svint8_t'} } */
28 };
29
30 /* Pointers to sizeless types. */
31
32 svint8_t *global_sve_sc_ptr;
33 svint8_t *invalid_sve_sc_ptr = &(svint8_t) {}; /* { dg-error {SVE type 'svint8_t' does not have a fixed size} } */
34
35 /* Sizeless arguments and return values. */
36
37 void ext_consume_sve_sc (svint8_t);
38 void ext_consume_varargs (int, ...);
39 svint8_t ext_produce_sve_sc ();
40
41 extern int bar (void);
42
43 /* Main tests for statements and expressions. */
44
45 void
46 statements (int n)
47 {
48 /* Local declarations. */
49
50 unsigned char va __attribute__((__vector_size__(2)));
51 svint8_t sve_sc1, sve_sc2;
52 _Atomic svint8_t atomic_sve_sc;
53 int8x32_t gnu_sc1;
54 svint16_t sve_sh1;
55 static svint8_t local_static_sve_sc; /* { dg-error {SVE type 'svint8_t' does not have a fixed size} } */
56
57 /* Layout queries. */
58
59 sizeof (svint8_t); /* { dg-error {SVE type 'svint8_t' does not have a fixed size} } */
60 sizeof (sve_sc1); /* { dg-error {SVE type 'svint8_t' does not have a fixed size} } */
61 sizeof (ext_produce_sve_sc ()); /* { dg-error {SVE type 'svint8_t' does not have a fixed size} } */
62 _Alignof (svint8_t); /* { dg-error {SVE type 'svint8_t' does not have a defined alignment} } */
63 _Alignof (sve_sc1); /* { dg-error {SVE type 'svint8_t' does not have a defined alignment} } */
64 _Alignof (ext_produce_sve_sc ()); /* { dg-error {SVE type 'svint8_t' does not have a defined alignment} } */
65
66 /* Initialization. */
67
68 svint8_t init_sve_sc1 = sve_sc1;
69 svint8_t init_sve_sc2 = sve_sh1; /* { dg-error {incompatible types when initializing type 'svint8_t' using type 'svint16_t'} } */
70 svint8_t init_sve_sc3 = {};
71
72 int initi_a = sve_sc1; /* { dg-error {incompatible types when initializing type 'int' using type 'svint8_t'} } */
73 int initi_b = { sve_sc1 }; /* { dg-error {incompatible types when initializing type 'int' using type 'svint8_t'} } */
74 svint32_t init_sve_vc1 = { 0, 1 };
75 svint32_t init_sve_vc2 = { 0, bar () };
76 svint32_t init_sve_vc3 = { bar (), n };
77 svint32_t init_sve_vc4 = { 0, 1, 2, 3, 4, 5, 6, 7 };
78 svint32_t init_sve_vc5 = { 0, 1, bar (), 3, 4, 5, 6, 7 };
79 svint32_t init_sve_vc6 = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; /* { dg-warning {excess elements in vector initializer} } */
80 svint32_t init_sve_vc7 = { 0, 1, 2, 3, bar (), 5, 6, 7, 8 }; /* { dg-warning {excess elements in vector initializer} } */
81 svint32_t init_sve_vc8 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; /* { dg-warning {excess elements in vector initializer} } */
82 svint32_t init_sve_vc9 = { 0, bar (), 2, 3, 4, 5, 6, 7, 8, 9, n }; /* { dg-warning {excess elements in vector initializer} } */
83
84
85 /* Compound literals. */
86
87 (svint8_t) {};
88 (svint8_t) { sve_sc1 }; /* { dg-error {incompatible types when initializing type 'signed char' using type 'svint8_t'} } */
89
90 (int) { sve_sc1 }; /* { dg-error {incompatible types when initializing type 'int' using type 'svint8_t'} } */
91
92 /* Arrays. */
93
94 svint8_t array[2]; /* { dg-error {array elements cannot have SVE type 'svint8_t'} } */
95 svint8_t zero_length_array[0]; /* { dg-error {array elements cannot have SVE type 'svint8_t'} } */
96 svint8_t empty_init_array[] = {}; /* { dg-error {array elements cannot have SVE type 'svint8_t'} } */
97 typedef svint8_t vla_type[n]; /* { dg-error {array elements cannot have SVE type 'svint8_t'} } */
98
99 /* Assignment. */
100
101 n = sve_sc1; /* { dg-error {incompatible types when assigning to type 'int' from type 'svint8_t'} } */
102
103 sve_sc1 = 0; /* { dg-error {incompatible types when assigning to type 'svint8_t' from type 'int'} } */
104 sve_sc1 = sve_sc2;
105 sve_sc1 = sve_sh1; /* { dg-error {incompatible types when assigning to type 'svint8_t' from type 'svint16_t'} } */
106
107 /* Casting. */
108
109 (void) sve_sc1;
110 (svint8_t) sve_sc1;
111
112 /* Addressing and dereferencing. */
113
114 svint8_t *sve_sc_ptr = &sve_sc1;
115 int8x32_t *gnu_sc_ptr = &gnu_sc1;
116 sve_sc1 = *sve_sc_ptr;
117
118 /* Pointer assignment. */
119
120 gnu_sc_ptr = sve_sc_ptr; /* { dg-error {incompatible pointer type} } */
121 sve_sc_ptr = gnu_sc_ptr; /* { dg-error {incompatible pointer type} } */
122
123 /* Pointer arithmetic. */
124
125 ++sve_sc_ptr; /* { dg-error {arithmetic on pointer to SVE type 'svint8_t'} } */
126 --sve_sc_ptr; /* { dg-error {arithmetic on pointer to SVE type 'svint8_t'} } */
127 sve_sc_ptr++; /* { dg-error {arithmetic on pointer to SVE type 'svint8_t'} } */
128 sve_sc_ptr--; /* { dg-error {arithmetic on pointer to SVE type 'svint8_t'} } */
129 sve_sc_ptr += 0; /* { dg-error {arithmetic on pointer to SVE type 'svint8_t'} } */
130 sve_sc_ptr += 1; /* { dg-error {arithmetic on pointer to SVE type 'svint8_t'} } */
131 sve_sc_ptr -= 0; /* { dg-error {arithmetic on pointer to SVE type 'svint8_t'} } */
132 sve_sc_ptr -= 1; /* { dg-error {arithmetic on pointer to SVE type 'svint8_t'} } */
133 sve_sc_ptr - sve_sc_ptr; /* { dg-error {arithmetic on pointer to SVE type 'svint8_t'} } */
134 gnu_sc_ptr - sve_sc_ptr; /* { dg-error {invalid operands to binary -} } */
135 sve_sc_ptr - gnu_sc_ptr; /* { dg-error {invalid operands to binary -} } */
136 sve_sc1 = sve_sc_ptr[0]; /* { dg-error {arithmetic on pointer to SVE type 'svint8_t'} } */
137 sve_sc1 = sve_sc_ptr[1]; /* { dg-error {arithmetic on pointer to SVE type 'svint8_t'} } */
138
139 /* Pointer comparison. */
140
141 sve_sc_ptr == &sve_sc1;
142 sve_sc_ptr != &sve_sc1;
143 sve_sc_ptr < &sve_sc1;
144 sve_sc_ptr <= &sve_sc1;
145 sve_sc_ptr > &sve_sc1;
146 sve_sc_ptr >= &sve_sc1;
147 gnu_sc_ptr == sve_sc_ptr; /* { dg-warning {comparison of distinct pointer types} } */
148 gnu_sc_ptr != sve_sc_ptr; /* { dg-warning {comparison of distinct pointer types} } */
149 gnu_sc_ptr < sve_sc_ptr; /* { dg-warning {comparison of distinct pointer types} } */
150 gnu_sc_ptr <= sve_sc_ptr; /* { dg-warning {comparison of distinct pointer types} } */
151 gnu_sc_ptr > sve_sc_ptr; /* { dg-warning {comparison of distinct pointer types} } */
152 gnu_sc_ptr >= sve_sc_ptr; /* { dg-warning {comparison of distinct pointer types} } */
153 sve_sc_ptr == gnu_sc_ptr; /* { dg-warning {comparison of distinct pointer types} } */
154 sve_sc_ptr != gnu_sc_ptr; /* { dg-warning {comparison of distinct pointer types} } */
155 sve_sc_ptr < gnu_sc_ptr; /* { dg-warning {comparison of distinct pointer types} } */
156 sve_sc_ptr <= gnu_sc_ptr; /* { dg-warning {comparison of distinct pointer types} } */
157 sve_sc_ptr > gnu_sc_ptr; /* { dg-warning {comparison of distinct pointer types} } */
158 sve_sc_ptr >= gnu_sc_ptr; /* { dg-warning {comparison of distinct pointer types} } */
159
160 /* Conditional expressions. */
161
162 0 ? sve_sc1 : sve_sc1;
163 0 ? sve_sc1 : sve_sh1; /* { dg-error {type mismatch in conditional expression} } */
164 0 ? sve_sc1 : 0; /* { dg-error {type mismatch in conditional expression} } */
165 0 ? 0 : sve_sc1; /* { dg-error {type mismatch in conditional expression} } */
166 0 ?: sve_sc1; /* { dg-error {type mismatch in conditional expression} } */
167 0 ? sve_sc_ptr : sve_sc_ptr;
168 0 ? sve_sc_ptr : gnu_sc_ptr; /* { dg-error {pointer type mismatch} } */
169 0 ? gnu_sc_ptr : sve_sc_ptr; /* { dg-error {pointer type mismatch} } */
170
171 /* Generic associations. */
172
173 _Generic (sve_sc1, default: 100);
174 _Generic (1, svint8_t: 10, default: 20);
175
176 /* Function arguments. */
177
178 ext_consume_sve_sc (sve_sc1);
179 ext_consume_sve_sc (sve_sh1); /* { dg-error {incompatible type for argument 1 of 'ext_consume_sve_sc'} } */
180 ext_consume_varargs (sve_sc1); /* { dg-error {incompatible type for argument 1 of 'ext_consume_varargs'} } */
181 ext_consume_varargs (1, sve_sc1);
182
183 /* Function returns. */
184
185 ext_produce_sve_sc ();
186 sve_sc1 = ext_produce_sve_sc ();
187 sve_sh1 = ext_produce_sve_sc (); /* { dg-error {incompatible types when assigning to type 'svint16_t' from type 'svint8_t'} } */
188
189 /* Varargs processing. */
190
191 __builtin_va_list valist;
192 __builtin_va_arg (valist, svint8_t);
193
194 /* Statement expressions. */
195
196 ({ sve_sc1; });
197 ({ svint8_t another_sve_sc = *sve_sc_ptr; another_sve_sc; });
198 }
199
200 /* Function parameters in definitions. */
201
202 void
203 old_style (input_sve_sc) /* { dg-error {SVE type 'svint8_t' cannot be passed to an unprototyped function} } */
204 svint8_t input_sve_sc;
205 {
206 svint8_t sve_sc1 = input_sve_sc;
207 }
208
209 void
210 new_style_param (svint8_t input_sve_sc)
211 {
212 svint8_t sve_sc1 = input_sve_sc;
213 }
214
215 /* Function return values in definitions. */
216
217 svint8_t
218 good_return_sve_sc (svint8_t param)
219 {
220 return param;
221 }
222
223 svint8_t
224 bad_return_sve_sc (svint16_t param)
225 {
226 return param; /* { dg-error {incompatible types when returning type 'svint16_t' but 'svint8_t' was expected} } */
227 }