@@ -322,10 +322,12 @@ constant_exprt smt2_convt::parse_literal(
322
322
}
323
323
else if (type.id ()==ID_c_enum_tag)
324
324
{
325
- return
326
- from_integer (
327
- value,
328
- ns.follow_tag (to_c_enum_tag_type (type)));
325
+ constant_exprt result =
326
+ from_integer (value, ns.follow_tag (to_c_enum_tag_type (type)));
327
+
328
+ // restore the c_enum_tag type
329
+ result.type () = type;
330
+ return result;
329
331
}
330
332
else if (type.id ()==ID_fixedbv ||
331
333
type.id ()==ID_floatbv)
@@ -335,7 +337,9 @@ constant_exprt smt2_convt::parse_literal(
335
337
}
336
338
else if (type.id ()==ID_integer ||
337
339
type.id ()==ID_range)
340
+ {
338
341
return from_integer (value, type);
342
+ }
339
343
else
340
344
INVARIANT (
341
345
false ,
@@ -388,25 +392,24 @@ exprt smt2_convt::parse_union(
388
392
return union_exprt (first.get_name (), converted, type);
389
393
}
390
394
391
- exprt smt2_convt::parse_struct (
392
- const irept &src,
393
- const struct_typet &type)
395
+ struct_exprt
396
+ smt2_convt::parse_struct (const irept &src, const struct_typet &type)
394
397
{
395
398
const struct_typet::componentst &components =
396
399
type.components ();
397
400
398
401
struct_exprt result (exprt::operandst (components.size (), nil_exprt ()), type);
399
402
400
403
if (components.empty ())
401
- return std::move ( result) ;
404
+ return result;
402
405
403
406
if (use_datatypes)
404
407
{
405
408
// Structs look like:
406
409
// (mk-struct.1 <component0> <component1> ... <componentN>)
407
410
408
411
if (src.get_sub ().size ()!=components.size ()+1 )
409
- return std::move ( result) ; // give up
412
+ return result; // give up
410
413
411
414
for (std::size_t i=0 ; i<components.size (); i++)
412
415
{
@@ -446,20 +449,17 @@ exprt smt2_convt::parse_struct(
446
449
}
447
450
}
448
451
449
- return std::move ( result) ;
452
+ return result;
450
453
}
451
454
452
- exprt smt2_convt::parse_rec (const irept &src, const typet &_type )
455
+ exprt smt2_convt::parse_rec (const irept &src, const typet &type )
453
456
{
454
- const typet &type=ns.follow (_type);
455
-
456
- if (type.id ()==ID_signedbv ||
457
- type.id ()==ID_unsignedbv ||
458
- type.id ()==ID_integer ||
459
- type.id ()==ID_rational ||
460
- type.id ()==ID_real ||
461
- type.id ()==ID_fixedbv ||
462
- type.id ()==ID_floatbv)
457
+ if (
458
+ type.id () == ID_signedbv || type.id () == ID_unsignedbv ||
459
+ type.id () == ID_integer || type.id () == ID_rational ||
460
+ type.id () == ID_real || type.id () == ID_c_enum ||
461
+ type.id () == ID_c_enum_tag || type.id () == ID_fixedbv ||
462
+ type.id () == ID_floatbv)
463
463
{
464
464
return parse_literal (src, type);
465
465
}
@@ -489,10 +489,25 @@ exprt smt2_convt::parse_rec(const irept &src, const typet &_type)
489
489
{
490
490
return parse_struct (src, to_struct_type (type));
491
491
}
492
+ else if (type.id () == ID_struct_tag)
493
+ {
494
+ auto struct_expr =
495
+ parse_struct (src, ns.follow_tag (to_struct_tag_type (type)));
496
+ // restore the tag type
497
+ struct_expr.type () = type;
498
+ return std::move (struct_expr);
499
+ }
492
500
else if (type.id ()==ID_union)
493
501
{
494
502
return parse_union (src, to_union_type (type));
495
503
}
504
+ else if (type.id () == ID_union_tag)
505
+ {
506
+ auto union_expr = parse_union (src, ns.follow_tag (to_union_tag_type (type)));
507
+ // restore the tag type
508
+ union_expr.type () = type;
509
+ return union_expr;
510
+ }
496
511
else if (type.id ()==ID_array)
497
512
{
498
513
return parse_array (src, to_array_type (type));
0 commit comments