1 /* { dg-do compile } */
2 /* { dg-options "-msse2 -O2" } */
15 __bf16 foo1 (void) { return (__bf16) 0x1234; } /* { dg-error {invalid conversion to type '__bf16'} } */
16 __bf16 foo2 (void) { return (__bf16) (short) 0x1234; } /* { dg-error {invalid conversion to type '__bf16'} } */
18 __bf16 footest (__bf16 scalar0)
24 __bf16 scalar1_2 = glob_bfloat;
25 __bf16 scalar1_3 = 0; /* { dg-error {invalid conversion to type '__bf16'} } */
26 __bf16 scalar1_4 = 0.1; /* { dg-error {invalid conversion to type '__bf16'} } */
27 __bf16 scalar1_5 = is_a_float; /* { dg-error {invalid conversion to type '__bf16'} } */
28 __bf16 scalar1_6 = is_an_int; /* { dg-error {invalid conversion to type '__bf16'} } */
29 __bf16 scalar1_7 = is_a_float16; /* { dg-error {invalid conversion to type '__bf16'} } */
30 __bf16 scalar1_8 = is_a_double; /* { dg-error {invalid conversion to type '__bf16'} } */
31 __bf16 scalar1_9 = is_a_short_int; /* { dg-error {invalid conversion to type '__bf16'} } */
33 int initi_1_1 = glob_bfloat; /* { dg-error {invalid conversion from type '__bf16'} } */
34 float initi_1_2 = glob_bfloat; /* { dg-error {invalid conversion from type '__bf16'} } */
35 _Float16 initi_1_3 = glob_bfloat; /* { dg-error {invalid conversion from type '__bf16'} } */
36 short initi_1_4 = glob_bfloat; /* { dg-error {invalid conversion from type '__bf16'} } */
37 double initi_1_5 = glob_bfloat; /* { dg-error {invalid conversion from type '__bf16'} } */
39 __bf16 scalar2_1 = {};
40 __bf16 scalar2_2 = { glob_bfloat };
41 __bf16 scalar2_3 = { 0 }; /* { dg-error {invalid conversion to type '__bf16'} } */
42 __bf16 scalar2_4 = { 0.1 }; /* { dg-error {invalid conversion to type '__bf16'} } */
43 __bf16 scalar2_5 = { is_a_float }; /* { dg-error {invalid conversion to type '__bf16'} } */
44 __bf16 scalar2_6 = { is_an_int }; /* { dg-error {invalid conversion to type '__bf16'} } */
45 __bf16 scalar2_7 = { is_a_float16 }; /* { dg-error {invalid conversion to type '__bf16'} } */
46 __bf16 scalar2_8 = { is_a_double }; /* { dg-error {invalid conversion to type '__bf16'} } */
47 __bf16 scalar2_9 = { is_a_short_int }; /* { dg-error {invalid conversion to type '__bf16'} } */
49 int initi_2_1 = { glob_bfloat }; /* { dg-error {invalid conversion from type '__bf16'} } */
50 float initi_2_2 = { glob_bfloat }; /* { dg-error {invalid conversion from type '__bf16'} } */
51 _Float16 initi_2_3 = { glob_bfloat }; /* { dg-error {invalid conversion from type '__bf16'} } */
52 short initi_2_4 = { glob_bfloat }; /* { dg-error {invalid conversion from type '__bf16'} } */
53 double initi_2_5 = { glob_bfloat }; /* { dg-error {invalid conversion from type '__bf16'} } */
57 glob_bfloat = glob_bfloat;
58 glob_bfloat = 0; /* { dg-error {invalid conversion to type '__bf16'} } */
59 glob_bfloat = 0.1; /* { dg-error {invalid conversion to type '__bf16'} } */
60 glob_bfloat = is_a_float; /* { dg-error {invalid conversion to type '__bf16'} } */
61 glob_bfloat = is_an_int; /* { dg-error {invalid conversion to type '__bf16'} } */
62 glob_bfloat = is_a_float16; /* { dg-error {invalid conversion to type '__bf16'} } */
63 glob_bfloat = is_a_double; /* { dg-error {invalid conversion to type '__bf16'} } */
64 glob_bfloat = is_a_short_int; /* { dg-error {invalid conversion to type '__bf16'} } */
66 is_an_int = glob_bfloat; /* { dg-error {invalid conversion from type '__bf16'} } */
67 is_a_float = glob_bfloat; /* { dg-error {invalid conversion from type '__bf16'} } */
68 is_a_float16 = glob_bfloat; /* { dg-error {invalid conversion from type '__bf16'} } */
69 is_a_double = glob_bfloat; /* { dg-error {invalid conversion from type '__bf16'} } */
70 is_a_short_int = glob_bfloat; /* { dg-error {invalid conversion from type '__bf16'} } */
77 (int) glob_bfloat; /* { dg-error {invalid conversion from type '__bf16'} } */
78 (float) glob_bfloat; /* { dg-error {invalid conversion from type '__bf16'} } */
79 (_Float16) glob_bfloat; /* { dg-error {invalid conversion from type '__bf16'} } */
80 (double) glob_bfloat; /* { dg-error {invalid conversion from type '__bf16'} } */
81 (short) glob_bfloat; /* { dg-error {invalid conversion from type '__bf16'} } */
83 (__bf16) is_an_int; /* { dg-error {invalid conversion to type '__bf16'} } */
84 (__bf16) is_a_float; /* { dg-error {invalid conversion to type '__bf16'} } */
85 (__bf16) is_a_float16; /* { dg-error {invalid conversion to type '__bf16'} } */
86 (__bf16) is_a_double; /* { dg-error {invalid conversion to type '__bf16'} } */
87 (__bf16) is_a_short_int; /* { dg-error {invalid conversion to type '__bf16'} } */
89 /* Compound literals. */
92 (__bf16) { glob_bfloat };
93 (__bf16) { 0 }; /* { dg-error {invalid conversion to type '__bf16'} } */
94 (__bf16) { 0.1 }; /* { dg-error {invalid conversion to type '__bf16'} } */
95 (__bf16) { is_a_float }; /* { dg-error {invalid conversion to type '__bf16'} } */
96 (__bf16) { is_an_int }; /* { dg-error {invalid conversion to type '__bf16'} } */
97 (__bf16) { is_a_float16 }; /* { dg-error {invalid conversion to type '__bf16'} } */
98 (__bf16) { is_a_double }; /* { dg-error {invalid conversion to type '__bf16'} } */
99 (__bf16) { is_a_short_int }; /* { dg-error {invalid conversion to type '__bf16'} } */
101 (int) { glob_bfloat }; /* { dg-error {invalid conversion from type '__bf16'} } */
102 (float) { glob_bfloat }; /* { dg-error {invalid conversion from type '__bf16'} } */
103 (_Float16) { glob_bfloat }; /* { dg-error {invalid conversion from type '__bf16'} } */
104 (double) { glob_bfloat }; /* { dg-error {invalid conversion from type '__bf16'} } */
105 (short) { glob_bfloat }; /* { dg-error {invalid conversion from type '__bf16'} } */
107 /* Arrays and Structs. */
109 typedef __bf16 array_type[2];
110 extern __bf16 extern_array[];
113 __bf16 zero_length_array[0];
114 __bf16 empty_init_array[] = {};
115 typedef __bf16 some_other_type[is_an_int];
125 /* Addressing and dereferencing. */
127 __bf16 *bfloat_ptr = &scalar0;
128 scalar0 = *bfloat_ptr;
130 /* Pointer assignment. */
132 __bf16 *bfloat_ptr2 = bfloat_ptr;
133 __bf16 *bfloat_ptr3 = array;
135 /* Pointer arithmetic. */
143 bfloat_ptr - bfloat_ptr2;
144 bfloat_ptr = &bfloat_ptr3[0];
145 bfloat_ptr = &bfloat_ptr3[1];
147 /* Simple comparison. */
148 scalar0 > glob_bfloat; /* { dg-error {operation not permitted on type '__bf16'} } */
149 glob_bfloat == scalar0; /* { dg-error {operation not permitted on type '__bf16'} } */
150 scalar0 > is_a_float; /* { dg-error {operation not permitted on type '__bf16'} } */
151 is_a_float == scalar0; /* { dg-error {operation not permitted on type '__bf16'} } */
152 scalar0 > 0; /* { dg-error {operation not permitted on type '__bf16'} } */
153 0 == scalar0; /* { dg-error {operation not permitted on type '__bf16'} } */
154 scalar0 > 0.1; /* { dg-error {operation not permitted on type '__bf16'} } */
155 0.1 == scalar0; /* { dg-error {operation not permitted on type '__bf16'} } */
156 scalar0 > is_an_int; /* { dg-error {operation not permitted on type '__bf16'} } */
157 is_an_int == scalar0; /* { dg-error {operation not permitted on type '__bf16'} } */
159 /* Pointer comparison. */
161 bfloat_ptr == &scalar0;
162 bfloat_ptr != &scalar0;
163 bfloat_ptr < &scalar0;
164 bfloat_ptr <= &scalar0;
165 bfloat_ptr > &scalar0;
166 bfloat_ptr >= &scalar0;
167 bfloat_ptr == bfloat_ptr2;
168 bfloat_ptr != bfloat_ptr2;
169 bfloat_ptr < bfloat_ptr2;
170 bfloat_ptr <= bfloat_ptr2;
171 bfloat_ptr > bfloat_ptr2;
172 bfloat_ptr >= bfloat_ptr2;
174 /* Conditional expressions. */
176 0 ? scalar0 : scalar0;
177 0 ? scalar0 : is_a_float; /* { dg-error {invalid conversion from type '__bf16'} } */
178 0 ? is_a_float : scalar0; /* { dg-error {invalid conversion from type '__bf16'} } */
179 0 ? scalar0 : 0; /* { dg-error {invalid conversion to type '__bf16'} } */
180 0 ? 0 : scalar0; /* { dg-error {invalid conversion to type '__bf16'} } */
181 0 ? 0.1 : scalar0; /* { dg-error {invalid conversion from type '__bf16'} } */
182 0 ? scalar0 : 0.1; /* { dg-error {invalid conversion from type '__bf16'} } */
183 0 ? bfloat_ptr : bfloat_ptr2;
184 0 ? bfloat_ptr : float_ptr; /* { dg-warning {pointer type mismatch in conditional expression} } */
185 0 ? float_ptr : bfloat_ptr; /* { dg-warning {pointer type mismatch in conditional expression} } */
187 scalar0 ? scalar0 : scalar0; /* { dg-error {operation not permitted on type '__bf16'} } */
188 scalar0 ? is_a_float : scalar0; /* { dg-error {operation not permitted on type '__bf16'} } */
189 scalar0 ? scalar0 : is_a_float; /* { dg-error {operation not permitted on type '__bf16'} } */
190 scalar0 ? is_a_float : is_a_float; /* { dg-error {operation not permitted on type '__bf16'} } */
192 /* Unary operators. */
194 +scalar0; /* { dg-error {operation not permitted on type '__bf16'} } */
195 -scalar0; /* { dg-error {operation not permitted on type '__bf16'} } */
196 ~scalar0; /* { dg-error {operation not permitted on type '__bf16'} } */
197 !scalar0; /* { dg-error {operation not permitted on type '__bf16'} } */
198 *scalar0; /* { dg-error {invalid type argument of unary '\*'} } */
199 __real scalar0; /* { dg-error {operation not permitted on type '__bf16'} } */
200 __imag scalar0; /* { dg-error {operation not permitted on type '__bf16'} } */
201 ++scalar0; /* { dg-error {operation not permitted on type '__bf16'} } */
202 --scalar0; /* { dg-error {operation not permitted on type '__bf16'} } */
203 scalar0++; /* { dg-error {operation not permitted on type '__bf16'} } */
204 scalar0--; /* { dg-error {operation not permitted on type '__bf16'} } */
206 /* Binary arithmetic operations. */
208 scalar0 = glob_bfloat + *bfloat_ptr; /* { dg-error {operation not permitted on type '__bf16'} } */
209 scalar0 = glob_bfloat + 0.1; /* { dg-error {operation not permitted on type '__bf16'} } */
210 scalar0 = glob_bfloat + 0; /* { dg-error {operation not permitted on type '__bf16'} } */
211 scalar0 = glob_bfloat + is_a_float; /* { dg-error {operation not permitted on type '__bf16'} } */