@@ -1878,6 +1878,7 @@ Algorithm::t_combinational_block *Algorithm::gatherSubroutine(siliceParser::Subr
1878
1878
" cannot find subroutine '%s' declared called by subroutine '%s'" ,
1879
1879
P->IDENTIFIER ()->getText ().c_str (), nfo->name .c_str ());
1880
1880
}
1881
+ nfo->allowed_calls .insert (P->IDENTIFIER ()->getText ());
1881
1882
// add all inputs/outputs
1882
1883
for (auto ins : S->second ->inputs ) {
1883
1884
nfo->allowed_writes .insert (S->second ->vios .at (ins));
@@ -2215,6 +2216,17 @@ Algorithm::t_combinational_block* Algorithm::gatherSyncExec(siliceParser::SyncEx
2215
2216
// are we calling a subroutine?
2216
2217
auto S = m_Subroutines.find (sync ->joinExec ()->IDENTIFIER ()->getText ());
2217
2218
if (S != m_Subroutines.end ()) {
2219
+ // are we in a subroutine?
2220
+ if (_current->context .subroutine ) {
2221
+ // verify the call is allowed
2222
+ if (_current->context .subroutine ->allowed_calls .count (S->first ) == 0 ) {
2223
+ reportError (sync ->getSourceInterval (), -1 ,
2224
+ " subroutine '%s' calls other subroutine '%s' without permssion\n \
2225
+ add 'calls %s' to declaration if that was intended." ,
2226
+ _current->context .subroutine ->name .c_str (),
2227
+ S->first .c_str (), S->first .c_str ());
2228
+ }
2229
+ }
2218
2230
// yes! create a new block, call subroutine
2219
2231
t_combinational_block* after = addBlock (generateBlockName (), _current, nullptr , sync ->getSourceInterval ());
2220
2232
// has to be a state to return to
0 commit comments