2020#include < util/arith_tools.h>
2121#include < util/std_types.h>
2222
23+ #include " gcc_types.h"
24+
2325void ansi_c_convert_typet::read (const typet &type)
2426{
2527 clear ();
@@ -80,8 +82,20 @@ void ansi_c_convert_typet::read_rec(const typet &type)
8082 int32_cnt++;
8183 else if (type.id ()==ID_int64)
8284 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++;
8395 else if (type.id ()==ID_gcc_float128)
8496 gcc_float128_cnt++;
97+ else if (type.id ()==ID_gcc_float128x)
98+ gcc_float128x_cnt++;
8599 else if (type.id ()==ID_gcc_int128)
86100 gcc_int128_cnt++;
87101 else if (type.id ()==ID_gcc_attribute_mode)
@@ -248,7 +262,11 @@ void ansi_c_convert_typet::write(typet &type)
248262 unsigned_cnt || int_cnt || c_bool_cnt || proper_bool_cnt ||
249263 short_cnt || char_cnt || complex_cnt || long_cnt ||
250264 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)
252270 {
253271 error ().source_location =source_location;
254272 error () << " illegal type modifier for defined type" << eom;
@@ -305,27 +323,49 @@ void ansi_c_convert_typet::write(typet &type)
305323 << " found " << type.pretty () << eom;
306324 throw 0 ;
307325 }
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)
309330 {
310331 if (signed_cnt || unsigned_cnt || int_cnt || c_bool_cnt || proper_bool_cnt ||
311332 int8_cnt || int16_cnt || int32_cnt || int64_cnt ||
312333 gcc_int128_cnt || bv_cnt ||
313334 short_cnt || char_cnt)
314335 {
315336 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;
317338 throw 0 ;
318339 }
319340
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 )
321346 {
322347 error ().source_location =source_location;
323348 error () << " conflicting type modifiers" << eom;
324349 throw 0 ;
325350 }
326351
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;
329369 }
330370 else if (double_cnt || float_cnt)
331371 {
@@ -335,7 +375,7 @@ void ansi_c_convert_typet::write(typet &type)
335375 short_cnt || char_cnt)
336376 {
337377 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;
339379 throw 0 ;
340380 }
341381
0 commit comments