@@ -560,7 +560,25 @@ namespace LCompilers {
560560
561561 ASR::expr_t * get_bound (ASR::expr_t * arr_expr, int dim, std::string bound,
562562 Allocator& al) {
563+ ASR::ttype_t * x_mv_type = ASRUtils::expr_type (arr_expr);
564+ ASR::dimension_t * m_dims;
565+ int n_dims = ASRUtils::extract_dimensions_from_ttype (x_mv_type, m_dims);
566+ bool is_data_only_array = ASRUtils::is_fixed_size_array (m_dims, n_dims) && ASRUtils::get_asr_owner (arr_expr) &&
567+ ASR::is_a<ASR::StructType_t>(*ASRUtils::get_asr_owner (arr_expr));
563568 ASR::ttype_t * int32_type = ASRUtils::TYPE (ASR::make_Integer_t (al, arr_expr->base .loc , 4 ));
569+ if (is_data_only_array) {
570+ const Location& loc = arr_expr->base .loc ;
571+ ASR::expr_t * zero = ASRUtils::EXPR (ASR::make_IntegerConstant_t (al, loc, 0 , int32_type));
572+ ASR::expr_t * one = ASRUtils::EXPR (ASR::make_IntegerConstant_t (al, loc, 1 , int32_type));
573+ if ( bound == " ubound" ) {
574+ return ASRUtils::EXPR (ASR::make_IntegerBinOp_t (
575+ al, arr_expr->base .loc , m_dims[dim - 1 ].m_length , ASR::binopType::Sub, one, int32_type, nullptr ));
576+ }
577+ if ( m_dims[dim - 1 ].m_start != nullptr ) {
578+ return m_dims[dim - 1 ].m_start ;
579+ }
580+ return zero;
581+ }
564582 ASR::expr_t * dim_expr = ASRUtils::EXPR (ASR::make_IntegerConstant_t (al, arr_expr->base .loc , dim, int32_type));
565583 ASR::arrayboundType bound_type = ASR::arrayboundType::LBound;
566584 if ( bound == " ubound" ) {
0 commit comments