diff --git a/src/libasr/asr_utils.h b/src/libasr/asr_utils.h index a1e5336354..a4f68afd55 100644 --- a/src/libasr/asr_utils.h +++ b/src/libasr/asr_utils.h @@ -115,6 +115,17 @@ static inline ASR::ttype_t *type_get_past_array(ASR::ttype_t *f) } } +static inline ASR::ttype_t *type_get_past_const(ASR::ttype_t *f) +{ + if (ASR::is_a(*f)) { + ASR::Const_t *e = ASR::down_cast(f); + LCOMPILERS_ASSERT(!ASR::is_a(*e->m_type)); + return e->m_type; + } else { + return f; + } +} + static inline ASR::Variable_t* EXPR2VAR(const ASR::expr_t *f) { return ASR::down_cast(symbol_get_past_external( diff --git a/src/libasr/asr_verify.cpp b/src/libasr/asr_verify.cpp index 635302a880..42c39e45de 100644 --- a/src/libasr/asr_verify.cpp +++ b/src/libasr/asr_verify.cpp @@ -1015,6 +1015,22 @@ class VerifyVisitor : public BaseWalkVisitor BaseWalkVisitor::visit_ArrayConstant(x); } + void visit_dimension(const dimension_t &x) { + if (x.m_start) { + require_with_loc(ASR::is_a( + *ASRUtils::type_get_past_const(ASRUtils::expr_type(x.m_start))), + "Start dimension must be a signed integer", x.loc); + visit_expr(*x.m_start); + } + + if (x.m_length) { + require_with_loc(ASR::is_a( + *ASRUtils::type_get_past_const(ASRUtils::expr_type(x.m_length))), + "Length dimension must be a signed integer", x.loc); + visit_expr(*x.m_length); + } + } + void visit_Array(const Array_t& x) { visit_ttype(*x.m_type); require(x.n_dims != 0, "Array type cannot have 0 dimensions.")