Skip to content

Commit

Permalink
DEV: Added ASR verify for Select::m_enable_fall_through
Browse files Browse the repository at this point in the history
  • Loading branch information
czgdp1807 committed Jan 23, 2024
1 parent d8139bf commit a582cfe
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/libasr/asr_verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@ class VerifyVisitor : public BaseWalkVisitor<VerifyVisitor>
current_symtab = nullptr;
}

void visit_Select(const Select_t& x) {
bool fall_through = false;
for( int i = 0; i < x.n_body; i++ ) {
ASR::CaseStmt_t* case_stmt_t = ASR::down_cast<ASR::CaseStmt_t>(x.m_body[i]);
fall_through = fall_through || case_stmt_t->m_fall_through;
}
require(fall_through == x.m_enable_fall_through,
"Select_t::m_enable_fall_through should be " +
std::to_string(x.m_enable_fall_through));
BaseWalkVisitor<VerifyVisitor>::visit_Select(x);
}

// --------------------------------------------------------
// symbol instances:

Expand Down Expand Up @@ -889,7 +901,7 @@ class VerifyVisitor : public BaseWalkVisitor<VerifyVisitor>
}

SymbolTable* temp_scope = current_symtab;

if (asr_owner_sym && temp_scope->get_counter() != ASRUtils::symbol_parent_symtab(x.m_name)->get_counter() &&
!ASR::is_a<ASR::ExternalSymbol_t>(*x.m_name) && !ASR::is_a<ASR::Variable_t>(*x.m_name)) {
if (ASR::is_a<ASR::AssociateBlock_t>(*asr_owner_sym) || ASR::is_a<ASR::Block_t>(*asr_owner_sym)) {
Expand All @@ -899,7 +911,7 @@ class VerifyVisitor : public BaseWalkVisitor<VerifyVisitor>
}
} else {
function_dependencies.push_back(std::string(ASRUtils::symbol_name(x.m_name)));
}
}
}

if( ASR::is_a<ASR::ExternalSymbol_t>(*x.m_name) ) {
Expand Down Expand Up @@ -1040,7 +1052,7 @@ class VerifyVisitor : public BaseWalkVisitor<VerifyVisitor>
}

SymbolTable* temp_scope = current_symtab;

if (asr_owner_sym && temp_scope->get_counter() != ASRUtils::symbol_parent_symtab(x.m_name)->get_counter() &&
!ASR::is_a<ASR::ExternalSymbol_t>(*x.m_name) && !ASR::is_a<ASR::Variable_t>(*x.m_name)) {
if (ASR::is_a<ASR::AssociateBlock_t>(*asr_owner_sym) || ASR::is_a<ASR::Block_t>(*asr_owner_sym)) {
Expand All @@ -1050,7 +1062,7 @@ class VerifyVisitor : public BaseWalkVisitor<VerifyVisitor>
}
} else {
function_dependencies.push_back(std::string(ASRUtils::symbol_name(x.m_name)));
}
}
}

if( ASR::is_a<ASR::ExternalSymbol_t>(*x.m_name) ) {
Expand Down

0 comments on commit a582cfe

Please sign in to comment.