Skip to content
Open
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/modules/duplicate_module1.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CORE
duplicate_module1.smv

^file .* line 10: duplicate module name `main'$
^EXIT=2$
^SIGNAL=0$
--
12 changes: 12 additions & 0 deletions regression/smv/modules/duplicate_module1.smv
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
MODULE main

VAR x : boolean;

MODULE other

VAR y : boolean;

-- duplicate of main
MODULE main

VAR z : boolean;
14 changes: 14 additions & 0 deletions src/smvlang/smv_typecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Author: Daniel Kroening, kroening@kroening.com
#include <cassert>
#include <set>
#include <stack>
#include <unordered_set>

class smv_typecheckt:public typecheckt
{
Expand Down Expand Up @@ -3214,6 +3215,19 @@ void smv_typecheckt::typecheck()
if(module_identifier != "smv::main")
return;

// check for duplicate module names
{
std::unordered_set<irep_idt, irep_id_hash> module_names;
for(const auto &module : smv_parse_tree.module_list)
{
if(!module_names.insert(module.base_name).second)
{
throw errort().with_location(module.source_location)
<< "duplicate module name `" << module.base_name << "'";
}
}
}

// build the index
index = smv_indext{smv_parse_tree};

Expand Down
Loading