Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions regression/smv/range-type/empty.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CORE
empty.smv

^file empty\.smv line 4: range is empty$
^EXIT=2$
^SIGNAL=0$
--
5 changes: 5 additions & 0 deletions regression/smv/range-type/empty.smv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
MODULE main

-- wrong order
VAR x : 10..1;

14 changes: 12 additions & 2 deletions src/smvlang/smv_typecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,14 @@ smv_ranget smv_typecheckt::convert_type(const typet &src)
}
else if(src.id()==ID_range)
{
dest.from=string2integer(src.get_string(ID_from));
dest.to=string2integer(src.get_string(ID_to));
auto from = string2integer(src.get_string(ID_from));
auto to = string2integer(src.get_string(ID_to));

if(from > to)
throw errort().with_location(src.source_location()) << "range is empty";

dest.from = from;
dest.to = to;
}
else if(src.id()==ID_enumeration)
{
Expand Down Expand Up @@ -1232,6 +1238,10 @@ void smv_typecheckt::convert(smv_parse_treet::mc_varst &vars)
{
const smv_parse_treet::mc_vart &var = var_it.second;

// check the type, if given
if(var.type.is_not_nil() && var.type.id() != "submodule")
convert_type(var.type);

symbol.base_name = var_it.first;

if(var.identifier=="")
Expand Down
Loading