Debian Codegraph @

gcc/testsuite/gcc.target/aarch64/sve/acle/general/attributes_7.c

raw
1 /* { dg-options "-msve-vector-bits=256 -W -Wall" } */
2
3 #include <arm_sve.h>
4
5 #define N __ARM_FEATURE_SVE_BITS
6 #define FIXED_ATTR __attribute__ ((arm_sve_vector_bits (N)))
7 #define GNU_ATTR __attribute__ ((vector_size (N / 8)))
8
9 typedef svint8_t fixed_int8_t FIXED_ATTR;
10 typedef svint16_t fixed_int16_t FIXED_ATTR;
11
12 typedef svuint8_t fixed_uint8_t FIXED_ATTR;
13
14 typedef svbool_t fixed_bool_t FIXED_ATTR;
15
16 typedef int8_t gnu_int8_t GNU_ATTR;
17 typedef int16_t gnu_int16_t GNU_ATTR;
18
19 typedef uint8_t gnu_uint8_t GNU_ATTR;
20
21 typedef int bad_type_1 __attribute__ ((arm_sve_vector_bits (N))); // { dg-error {'arm_sve_vector_bits' applied to non-SVE type 'int'} }
22 typedef svbool_t bad_type_2 __attribute__ ((arm_sve_vector_bits)); // { dg-error {wrong number of arguments specified for 'arm_sve_vector_bits' attribute} }
23 typedef svbool_t bad_type_3 __attribute__ ((arm_sve_vector_bits (N, N))); // { dg-error {wrong number of arguments specified for 'arm_sve_vector_bits' attribute} }
24 typedef svbool_t bad_type_4 __attribute__ ((arm_sve_vector_bits ("256"))); // { dg-error {'arm_sve_vector_bits' requires an integer constant expression} }
25 typedef svbool_t bad_type_5 __attribute__ ((arm_sve_vector_bits (100))); // { dg-warning {unsupported SVE vector size} }
26 typedef svint32x2_t bad_type_6 __attribute__ ((arm_sve_vector_bits (N))); // { dg-error {'arm_sve_vector_bits' applied to non-vector type 'svint32x2_t'} }
27 typedef svint8_t bad_type_7 __attribute__ ((arm_sve_vector_bits (N))) __attribute__ ((arm_sve_vector_bits (N))); // { dg-error {'arm_sve_vector_bits' applied to type 'svint8_t __attribute__\(\(arm_sve_vector_bits\([0-9]+\)\)\)', which already has a size} }
28 typedef fixed_bool_t bad_type_8 __attribute__ ((arm_sve_vector_bits (N))) __attribute__ ((arm_sve_vector_bits (N))); // { dg-error {'arm_sve_vector_bits' applied to type 'fixed_bool_t' {aka 'svbool_t __attribute__\(\(arm_sve_vector_bits\([0-9]+\)\)\)'}, which already has a size} }
29 typedef gnu_int8_t bad_type_9 __attribute__ ((arm_sve_vector_bits (N))) __attribute__ ((arm_sve_vector_bits (N))); // { dg-error {'arm_sve_vector_bits' applied to non-SVE type 'gnu_int8_t'} }
30 typedef svcount_t bad_type_10 __attribute__ ((arm_sve_vector_bits (N))); // { dg-error {'arm_sve_vector_bits' applied to non-vector type 'svcount_t'} }
31
32 void
33 f (int c)
34 {
35 svint8_t ss8;
36 fixed_int8_t fs8;
37 gnu_int8_t gs8;
38
39 svuint8_t su8;
40 fixed_uint8_t fu8;
41 gnu_uint8_t gu8;
42
43 svint16_t ss16;
44 fixed_int16_t fs16;
45 gnu_int16_t gs16;
46
47 svbool_t sb;
48 fixed_bool_t fb;
49
50 ss8 = ss8 + ss8;
51 ss8 = ss8 + fs8;
52 ss8 = ss8 + gs8; /* { dg-error {cannot combine GNU and SVE vectors in a binary operation} } */
53 ss8 += ss8;
54 ss8 += fs8;
55 ss8 += gs8; /* { dg-error {cannot combine GNU and SVE vectors in a binary operation} } */
56
57 fs8 = fs8 + ss8;
58 fs8 = fs8 + fs8;
59 fs8 = fs8 + gs8; /* { dg-error {cannot combine GNU and SVE vectors in a binary operation} } */
60 fs8 += ss8;
61 fs8 += fs8;
62 fs8 += gs8; /* { dg-error {cannot combine GNU and SVE vectors in a binary operation} } */
63
64 gs8 = gs8 + ss8; /* { dg-error {cannot combine GNU and SVE vectors in a binary operation} } */
65 gs8 = gs8 + fs8; /* { dg-error {cannot combine GNU and SVE vectors in a binary operation} } */
66 gs8 = gs8 + gs8;
67 gs8 += ss8; /* { dg-error {cannot combine GNU and SVE vectors in a binary operation} } */
68 gs8 += fs8; /* { dg-error {cannot combine GNU and SVE vectors in a binary operation} } */
69 gs8 += gs8;
70
71 fs8 = ss8;
72 fs8 = fs8;
73 fs8 = gs8;
74
75 fs8 = su8; // { dg-error {cannot convert|incompatible types} }
76 fs8 = fu8; // { dg-error {cannot convert|incompatible types} }
77 fs8 = gu8; // { dg-error {cannot convert|incompatible types} }
78
79 fs8 = ss16; // { dg-error {cannot convert|incompatible types} }
80 fs8 = fs16; // { dg-error {cannot convert|incompatible types} }
81 fs8 = gs16; // { dg-error {cannot convert|incompatible types} }
82
83 (void) (c ? ss8 : ss8);
84 (void) (c ? ss8 : fs8); // { dg-error {type mismatch|different types} }
85 (void) (c ? ss8 : gs8); // { dg-error {type mismatch|different types} }
86
87 (void) (c ? fs8 : ss8); // { dg-error {type mismatch|different types} }
88 (void) (c ? fs8 : fs8);
89 (void) (c ? fs8 : gs8); // { dg-error {type mismatch|different types} }
90
91 (void) (c ? gs8 : ss8); // { dg-error {type mismatch|different types} }
92 (void) (c ? gs8 : fs8); // { dg-error {type mismatch|different types} }
93 (void) (c ? gs8 : gs8);
94
95 sb = fb;
96 fb = sb;
97
98 (void) (c ? sb : sb);
99 (void) (c ? sb : fb); // { dg-error {type mismatch|different types} "$tool" { xfail c } }
100
101 (void) (c ? fb : sb); // { dg-error {type mismatch|different types} "$tool" { xfail c } }
102 (void) (c ? fb : fb);
103 }
104
105 void
106 g (int c)
107 {
108 svint8_t *ss8;
109 fixed_int8_t *fs8;
110 gnu_int8_t *gs8;
111
112 svuint8_t *su8;
113 fixed_uint8_t *fu8;
114 gnu_uint8_t *gu8;
115
116 svint16_t *ss16;
117 fixed_int16_t *fs16;
118 gnu_int16_t *gs16;
119
120 svbool_t *sb;
121 fixed_bool_t *fb;
122
123 __PTRDIFF_TYPE__ diff __attribute__((unused));
124 void *select __attribute__((unused));
125
126 diff = ss8 - ss8; // { dg-error {arithmetic on pointer to SVE type 'svint8_t'} }
127 diff = ss8 - fs8; // { dg-error {invalid operands [^\n]* binary[^\n]*\-} "" }
128 diff = ss8 - gs8; // { dg-error {invalid operands [^\n]* binary[^\n]*\-} "" }
129
130 diff = fs8 - ss8; // { dg-error {invalid operands [^\n]* binary[^\n]*\-} "" }
131 diff = fs8 - fs8;
132 diff = fs8 - gs8; // { dg-error {invalid operands [^\n]* binary[^\n]*\-} "" }
133
134 diff = gs8 - ss8; // { dg-error {invalid operands [^\n]* binary[^\n]*\-} "" }
135 diff = gs8 - fs8; // { dg-error {invalid operands [^\n]* binary[^\n]*\-} "" }
136 diff = gs8 - gs8;
137
138 fs8 = ss8; // { dg-error {invalid conversion} "" { target c++ } }
139 // { dg-error {incompatible pointer type} "c" { target c } .-1 }
140 fs8 = fs8;
141 fs8 = gs8; // { dg-error {invalid conversion} "" { target c++ } }
142 // { dg-error {incompatible pointer type} "c" { target c } .-1 }
143
144 fs8 = su8; // { dg-error {cannot convert} "c++" { target c++ } }
145 // { dg-error {incompatible pointer type} "c" { target c } .-1 }
146 fs8 = fu8; // { dg-error {cannot convert} "c++" { target c++ } }
147 // { dg-error {incompatible pointer type} "c" { target c } .-1 }
148 fs8 = gu8; // { dg-error {cannot convert} "c++" { target c++ } }
149 // { dg-error {incompatible pointer type} "c" { target c } .-1 }
150
151 fs8 = ss16; // { dg-error {cannot convert} "c++" { target c++ } }
152 // { dg-error {incompatible pointer type} "c" { target c } .-1 }
153 fs8 = fs16; // { dg-error {cannot convert} "c++" { target c++ } }
154 // { dg-error {incompatible pointer type} "c" { target c } .-1 }
155 fs8 = gs16; // { dg-error {cannot convert} "c++" { target c++ } }
156 // { dg-error {incompatible pointer type} "c" { target c } .-1 }
157
158 select = c ? ss8 : ss8;
159 select = c ? ss8 : fs8; // { dg-error {distinct pointer types} "" { target c++ } }
160 // { dg-error {pointer type mismatch} "c" { target c } .-1 }
161 select = c ? ss8 : gs8; // { dg-error {distinct pointer types} "" { target c++ } }
162 // { dg-error {pointer type mismatch} "c" { target c } .-1 }
163
164 select = c ? fs8 : ss8; // { dg-error {distinct pointer types} "" { target c++ } }
165 // { dg-error {pointer type mismatch} "c" { target c } .-1 }
166 select = c ? fs8 : fs8;
167 select = c ? fs8 : gs8; // { dg-error {distinct pointer types} "" { target c++ } }
168 // { dg-error {pointer type mismatch} "c" { target c } .-1 }
169
170 select = c ? gs8 : ss8; // { dg-error {distinct pointer types} "" { target c++ } }
171 // { dg-error {pointer type mismatch} "c" { target c } .-1 }
172 select = c ? gs8 : fs8; // { dg-error {distinct pointer types} "" { target c++ } }
173 // { dg-error {pointer type mismatch} "c" { target c } .-1 }
174 select = c ? gs8 : gs8;
175
176 diff = sb - sb; // { dg-error {arithmetic on pointer to SVE type 'svbool_t'} }
177 diff = sb - fb; // { dg-error {invalid operands} "" { target c++ } }
178 // { dg-error {arithmetic on pointer to SVE type 'svbool_t'} "c" { target c } .-1 }
179
180 diff = fb - sb; // { dg-error {invalid operands} "" { target c++ } }
181 // { dg-error {arithmetic on pointer to SVE type 'svbool_t'} "c" { target c } .-1 }
182 diff = fb - fb;
183
184 sb = fb; // { dg-error {invalid conversion} "" { target c++ } }
185 // { dg-warning {incompatible pointer type} "c" { target c xfail c } .-1 }
186 fb = sb; // { dg-error {invalid conversion} "" { target c++ } }
187 // { dg-warning {incompatible pointer type} "c" { target c xfail c } .-1 }
188
189 select = c ? sb : sb;
190 select = c ? sb : fb; // { dg-error {distinct pointer types} "" { target c++ } }
191 // { dg-warning {pointer type mismatch} "c" { target c xfail c } .-1 }
192
193 select = c ? fb : sb; // { dg-error {distinct pointer types} "" { target c++ } }
194 // { dg-warning {pointer type mismatch} "c" { target c xfail c } .-1 }
195 select = c ? fb : fb;
196 }