20
20
#include < util/arith_tools.h>
21
21
#include < util/std_types.h>
22
22
23
+ #include " gcc_types.h"
24
+
23
25
void ansi_c_convert_typet::read (const typet &type)
24
26
{
25
27
clear ();
@@ -80,8 +82,20 @@ void ansi_c_convert_typet::read_rec(const typet &type)
80
82
int32_cnt++;
81
83
else if (type.id ()==ID_int64)
82
84
int64_cnt++;
85
+ else if (type.id ()==ID_gcc_float16)
86
+ gcc_float16_cnt++;
87
+ else if (type.id ()==ID_gcc_float32)
88
+ gcc_float32_cnt++;
89
+ else if (type.id ()==ID_gcc_float32x)
90
+ gcc_float32x_cnt++;
91
+ else if (type.id ()==ID_gcc_float64)
92
+ gcc_float64_cnt++;
93
+ else if (type.id ()==ID_gcc_float64x)
94
+ gcc_float64x_cnt++;
83
95
else if (type.id ()==ID_gcc_float128)
84
96
gcc_float128_cnt++;
97
+ else if (type.id ()==ID_gcc_float128x)
98
+ gcc_float128x_cnt++;
85
99
else if (type.id ()==ID_gcc_int128)
86
100
gcc_int128_cnt++;
87
101
else if (type.id ()==ID_gcc_attribute_mode)
@@ -248,7 +262,11 @@ void ansi_c_convert_typet::write(typet &type)
248
262
unsigned_cnt || int_cnt || c_bool_cnt || proper_bool_cnt ||
249
263
short_cnt || char_cnt || complex_cnt || long_cnt ||
250
264
int8_cnt || int16_cnt || int32_cnt || int64_cnt ||
251
- gcc_float128_cnt || gcc_int128_cnt || bv_cnt)
265
+ gcc_float16_cnt ||
266
+ gcc_float32_cnt || gcc_float32x_cnt ||
267
+ gcc_float64_cnt || gcc_float64x_cnt ||
268
+ gcc_float128_cnt || gcc_float128x_cnt ||
269
+ gcc_int128_cnt || bv_cnt)
252
270
{
253
271
error ().source_location =source_location;
254
272
error () << " illegal type modifier for defined type" << eom;
@@ -305,27 +323,49 @@ void ansi_c_convert_typet::write(typet &type)
305
323
<< " found " << type.pretty () << eom;
306
324
throw 0 ;
307
325
}
308
- else if (gcc_float128_cnt)
326
+ else if (gcc_float16_cnt ||
327
+ gcc_float32_cnt || gcc_float32x_cnt ||
328
+ gcc_float64_cnt || gcc_float64x_cnt ||
329
+ gcc_float128_cnt || gcc_float128x_cnt)
309
330
{
310
331
if (signed_cnt || unsigned_cnt || int_cnt || c_bool_cnt || proper_bool_cnt ||
311
332
int8_cnt || int16_cnt || int32_cnt || int64_cnt ||
312
333
gcc_int128_cnt || bv_cnt ||
313
334
short_cnt || char_cnt)
314
335
{
315
336
error ().source_location =source_location;
316
- error () << " cannot combine integer type with float " << eom;
337
+ error () << " cannot combine integer type with floating-point type " << eom;
317
338
throw 0 ;
318
339
}
319
340
320
- if (long_cnt || double_cnt || float_cnt)
341
+ if (long_cnt+double_cnt+
342
+ float_cnt+gcc_float16_cnt+
343
+ gcc_float32_cnt+gcc_float32x_cnt+
344
+ gcc_float64_cnt+gcc_float64x_cnt+
345
+ gcc_float128_cnt+gcc_float128x_cnt>=2 )
321
346
{
322
347
error ().source_location =source_location;
323
348
error () << " conflicting type modifiers" << eom;
324
349
throw 0 ;
325
350
}
326
351
327
- // _not_ the same as long double
328
- type=gcc_float128_type ();
352
+ // _not_ the same as float, double, long double
353
+ if (gcc_float16_cnt)
354
+ type=gcc_float16_type ();
355
+ else if (gcc_float32_cnt)
356
+ type=gcc_float32_type ();
357
+ else if (gcc_float32x_cnt)
358
+ type=gcc_float32x_type ();
359
+ else if (gcc_float64_cnt)
360
+ type=gcc_float64_type ();
361
+ else if (gcc_float64x_cnt)
362
+ type=gcc_float64x_type ();
363
+ else if (gcc_float128_cnt)
364
+ type=gcc_float128_type ();
365
+ else if (gcc_float128x_cnt)
366
+ type=gcc_float128x_type ();
367
+ else
368
+ UNREACHABLE;
329
369
}
330
370
else if (double_cnt || float_cnt)
331
371
{
@@ -335,7 +375,7 @@ void ansi_c_convert_typet::write(typet &type)
335
375
short_cnt || char_cnt)
336
376
{
337
377
error ().source_location =source_location;
338
- error () << " cannot combine integer type with float " << eom;
378
+ error () << " cannot combine integer type with floating-point type " << eom;
339
379
throw 0 ;
340
380
}
341
381
0 commit comments