Debian Codegraph @

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

raw
1 /* { dg-options "-std=gnu99" } */
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 };
78 svint32_t init_sve_vc5 = { 0, 1, bar (), 3 };
79 svint32_t init_sve_vc6 = { 0, 1, 2, 3, 4 }; /* { dg-error {excess elements in vector initializer} } */
80 svint32_t init_sve_vc7 = { 0, 1, 2, 3, bar () }; /* { dg-error {excess elements in vector initializer} } */
81 svint32_t init_sve_vc8 = { 0, 1, 2, 3, 4, 5 }; /* { dg-error {excess elements in vector initializer} } */
82 svint32_t init_sve_vc9 = { 0, bar (), 2, 3, 4, n }; /* { dg-error {excess elements in vector initializer} } */
83
84
85
86 /* Compound literals. */
87
88 (svint8_t) {};
89 (svint8_t) { sve_sc1 }; /* { dg-error {incompatible types when initializing type 'signed char' using type 'svint8_t'} } */
90
91 (int) { sve_sc1 }; /* { dg-error {incompatible types when initializing type 'int' using type 'svint8_t'} } */
92
93 /* Arrays. */
94
95 svint8_t array[2]; /* { dg-error {array elements cannot have SVE type 'svint8_t'} } */
96 svint8_t zero_length_array[0]; /* { dg-error {array elements cannot have SVE type 'svint8_t'} } */
97 svint8_t empty_init_array[] = {}; /* { dg-error {array elements cannot have SVE type 'svint8_t'} } */
98 typedef svint8_t vla_type[n]; /* { dg-error {array elements cannot have SVE type 'svint8_t'} } */
99
100 /* Assignment. */
101
102 n = sve_sc1; /* { dg-error {incompatible types when assigning to type 'int' from type 'svint8_t'} } */
103
104 sve_sc1 = 0; /* { dg-error {incompatible types when assigning to type 'svint8_t' from type 'int'} } */
105 sve_sc1 = sve_sc2;
106 sve_sc1 = sve_sh1; /* { dg-error {incompatible types when assigning to type 'svint8_t' from type 'svint16_t'} } */
107
108 /* Casting. */
109
110 (void) sve_sc1;
111 (svint8_t) sve_sc1;
112
113 /* Addressing and dereferencing. */
114
115 svint8_t *sve_sc_ptr = &sve_sc1;
116 int8x32_t *gnu_sc_ptr = &gnu_sc1;
117 sve_sc1 = *sve_sc_ptr;
118
119 /* Pointer assignment. */
120
121 gnu_sc_ptr = sve_sc_ptr; /* { dg-error {assignment to [^\n]* from incompatible pointer type} } */
122 sve_sc_ptr = gnu_sc_ptr; /* { dg-error {assignment to [^\n]* from incompatible pointer type} } */
123
124 /* Pointer arithmetic. */
125
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--; /* { dg-error {arithmetic on pointer to SVE type 'svint8_t'} } */
130 sve_sc_ptr += 0; /* { dg-error {arithmetic on pointer to SVE type 'svint8_t'} } */
131 sve_sc_ptr += 1; /* { dg-error {arithmetic on pointer to SVE type 'svint8_t'} } */
132 sve_sc_ptr -= 0; /* { dg-error {arithmetic on pointer to SVE type 'svint8_t'} } */
133 sve_sc_ptr -= 1; /* { dg-error {arithmetic on pointer to SVE type 'svint8_t'} } */
134 sve_sc_ptr - sve_sc_ptr; /* { dg-error {arithmetic on pointer to SVE type 'svint8_t'} } */
135 gnu_sc_ptr - sve_sc_ptr; /* { dg-error {invalid operands to binary -} } */
136 sve_sc_ptr - gnu_sc_ptr; /* { dg-error {invalid operands to binary -} } */
137 sve_sc1 = sve_sc_ptr[0]; /* { dg-error {arithmetic on pointer to SVE type 'svint8_t'} } */
138 sve_sc1 = sve_sc_ptr[1]; /* { dg-error {arithmetic on pointer to SVE type 'svint8_t'} } */
139
140 /* Pointer comparison. */
141
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 sve_sc_ptr >= &sve_sc1;
148 gnu_sc_ptr == sve_sc_ptr; /* { dg-warning {comparison of distinct pointer types lacks a cast} } */
149 gnu_sc_ptr != sve_sc_ptr; /* { dg-warning {comparison of distinct pointer types lacks a cast} } */
150 gnu_sc_ptr < sve_sc_ptr; /* { dg-warning {comparison of distinct pointer types lacks a cast} } */
151 gnu_sc_ptr <= sve_sc_ptr; /* { dg-warning {comparison of distinct pointer types lacks a cast} } */
152 gnu_sc_ptr > sve_sc_ptr; /* { dg-warning {comparison of distinct pointer types lacks a cast} } */
153 gnu_sc_ptr >= sve_sc_ptr; /* { dg-warning {comparison of distinct pointer types lacks a cast} } */
154 sve_sc_ptr == gnu_sc_ptr; /* { dg-warning {comparison of distinct pointer types lacks a cast} } */
155 sve_sc_ptr != gnu_sc_ptr; /* { dg-warning {comparison of distinct pointer types lacks a cast} } */
156 sve_sc_ptr < gnu_sc_ptr; /* { dg-warning {comparison of distinct pointer types lacks a cast} } */
157 sve_sc_ptr <= gnu_sc_ptr; /* { dg-warning {comparison of distinct pointer types lacks a cast} } */
158 sve_sc_ptr > gnu_sc_ptr; /* { dg-warning {comparison of distinct pointer types lacks a cast} } */
159 sve_sc_ptr >= gnu_sc_ptr; /* { dg-warning {comparison of distinct pointer types lacks a cast} } */
160
161 /* Conditional expressions. */
162
163 0 ? sve_sc1 : sve_sc1;
164 0 ? sve_sc1 : sve_sh1; /* { dg-error {type mismatch in conditional expression} } */
165 0 ? sve_sc1 : 0; /* { dg-error {type mismatch in conditional expression} } */
166 0 ? 0 : sve_sc1; /* { dg-error {type mismatch in conditional expression} } */
167 0 ?: sve_sc1; /* { dg-error {type mismatch in conditional expression} } */
168 0 ? sve_sc_ptr : sve_sc_ptr;
169 0 ? sve_sc_ptr : gnu_sc_ptr; /* { dg-error {pointer type mismatch in conditional expression} } */
170 0 ? gnu_sc_ptr : sve_sc_ptr; /* { dg-error {pointer type mismatch in conditional expression} } */
171
172 /* Generic associations. */
173
174 _Generic (sve_sc1, default: 100);
175 _Generic (1, svint8_t: 10, default: 20);
176
177 /* Function arguments. */
178
179 ext_consume_sve_sc (sve_sc1);
180 ext_consume_sve_sc (sve_sh1); /* { dg-error {incompatible type for argument 1 of 'ext_consume_sve_sc'} } */
181 ext_consume_varargs (sve_sc1); /* { dg-error {incompatible type for argument 1 of 'ext_consume_varargs'} } */
182 ext_consume_varargs (1, sve_sc1);
183
184 /* Function returns. */
185
186 ext_produce_sve_sc ();
187 sve_sc1 = ext_produce_sve_sc ();
188 sve_sh1 = ext_produce_sve_sc (); /* { dg-error {incompatible types when assigning to type 'svint16_t' from type 'svint8_t'} } */
189
190 /* Varargs processing. */
191
192 __builtin_va_list valist;
193 __builtin_va_arg (valist, svint8_t);
194
195 /* Statement expressions. */
196
197 ({ sve_sc1; });
198 ({ svint8_t another_sve_sc = *sve_sc_ptr; another_sve_sc; });
199 }
200
201 /* Function parameters in definitions. */
202
203 void
204 old_style (input_sve_sc) /* { dg-error {SVE type 'svint8_t' cannot be passed to an unprototyped function} } */
205 svint8_t input_sve_sc;
206 {
207 svint8_t sve_sc1 = input_sve_sc;
208 }
209
210 void
211 new_style_param (svint8_t input_sve_sc)
212 {
213 svint8_t sve_sc1 = input_sve_sc;
214 }
215
216 /* Function return values in definitions. */
217
218 svint8_t
219 good_return_sve_sc (svint8_t param)
220 {
221 return param;
222 }
223
224 svint8_t
225 bad_return_sve_sc (svint16_t param)
226 {
227 return param; /* { dg-error {incompatible types when returning type 'svint16_t' but 'svint8_t' was expected} } */
228 }