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
4 changes: 2 additions & 2 deletions regression/verilog/modules/input_and_output.desc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
KNOWNBUG
CORE
input_and_output.v

^file .* line 4: port `x' is alrady declared$
^EXIT=2$
^SIGNAL=0$
--
--
This should be errored, as some_var must not be both input and output.
13 changes: 11 additions & 2 deletions src/verilog/verilog_elaborate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,23 @@ void verilog_typecheckt::collect_symbols(const verilog_declt &decl)
{
symbolt &osymbol = *result;

// 1800-2017 23.2.2.1
// "Once a name is used in a port declaration, it shall not be declared
// again in another port declaration"
if(osymbol.is_input || osymbol.is_output)
{
throw errort().with_location(declarator.source_location())
<< "port `" << symbol.base_name << "' is alrady declared";
}

if(symbol.type != osymbol.type)
{
if(get_width(symbol.type) > get_width(osymbol.type))
osymbol.type = symbol.type;
}

osymbol.is_input = symbol.is_input || osymbol.is_input;
osymbol.is_output = symbol.is_output || osymbol.is_output;
osymbol.is_input = symbol.is_input;
osymbol.is_output = symbol.is_output;
osymbol.is_state_var = symbol.is_state_var || osymbol.is_state_var;

// a register can't be an input as well
Expand Down
Loading