@@ -79,6 +79,7 @@ class smv_typecheckt:public typecheckt
79
79
const std::string &module ;
80
80
bool do_spec;
81
81
82
+ void check_type (const typet &);
82
83
smv_ranget convert_type (const typet &);
83
84
static bool is_contained_in (irep_idt, const enumeration_typet &);
84
85
@@ -475,6 +476,29 @@ void smv_typecheckt::typecheck_op(
475
476
476
477
/* ******************************************************************\
477
478
479
+ Function: smv_typecheckt::check_type
480
+
481
+ Inputs:
482
+
483
+ Outputs:
484
+
485
+ Purpose:
486
+
487
+ \*******************************************************************/
488
+
489
+ void smv_typecheckt::check_type (const typet &type)
490
+ {
491
+ if (type.id () == ID_range)
492
+ {
493
+ auto range = smv_ranget::from_type (to_range_type (type));
494
+
495
+ if (range.from > range.to )
496
+ throw errort ().with_location (type.source_location ()) << " range is empty" ;
497
+ }
498
+ }
499
+
500
+ /* ******************************************************************\
501
+
478
502
Function: smv_typecheckt::convert_type
479
503
480
504
Inputs:
@@ -487,22 +511,18 @@ Function: smv_typecheckt::convert_type
487
511
488
512
smv_ranget smv_typecheckt::convert_type (const typet &src)
489
513
{
490
- smv_ranget dest;
491
-
492
514
if (src.id ()==ID_bool)
493
515
{
494
- dest.from =0 ;
495
- dest.to =1 ;
516
+ return {0 , 1 };
496
517
}
497
518
else if (src.id ()==ID_range)
498
519
{
499
- dest = smv_ranget::from_type (to_range_type (src));
500
-
501
- if (dest.from > dest.to )
502
- throw errort ().with_location (src.source_location ()) << " range is empty" ;
520
+ return smv_ranget::from_type (to_range_type (src));
503
521
}
504
522
else if (src.id ()==ID_enumeration)
505
523
{
524
+ smv_ranget dest;
525
+
506
526
dest.from =0 ;
507
527
508
528
std::size_t number_of_elements=
@@ -512,14 +532,14 @@ smv_ranget smv_typecheckt::convert_type(const typet &src)
512
532
dest.to =0 ;
513
533
else
514
534
dest.to =(long long )number_of_elements-1 ;
535
+
536
+ return dest;
515
537
}
516
538
else
517
539
{
518
540
throw errort ().with_location (src.source_location ())
519
541
<< " Unexpected type: `" << to_string (src) << " '" ;
520
542
}
521
-
522
- return dest;
523
543
}
524
544
525
545
/* ******************************************************************\
@@ -1321,9 +1341,9 @@ void smv_typecheckt::convert(smv_parse_treet::mc_varst &vars)
1321
1341
{
1322
1342
const smv_parse_treet::mc_vart &var = var_it.second ;
1323
1343
1324
- // check the type, if given
1325
- if (var.type .is_not_nil () && var. type . id () != " submodule " )
1326
- convert_type (var.type );
1344
+ // check the type, if any
1345
+ if (var.type .is_not_nil ())
1346
+ check_type (var.type );
1327
1347
1328
1348
symbol.base_name = var_it.first ;
1329
1349
0 commit comments