From 3cdb2f63a0e9c50bf0e73c52656de44d02abdd69 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 11 Nov 2024 19:48:25 +0530 Subject: [PATCH 1/2] enh: array_size_t_util to support IntrinsicArrayFunction --- src/libasr/asr_utils.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libasr/asr_utils.h b/src/libasr/asr_utils.h index 0265a6df6d..ca7270483c 100644 --- a/src/libasr/asr_utils.h +++ b/src/libasr/asr_utils.h @@ -2586,6 +2586,17 @@ static inline ASR::asr_t* make_ArraySize_t_util( break; } } + } else if ( ASR::is_a(*a_v) && for_type ) { + ASR::IntrinsicArrayFunction_t* af = ASR::down_cast(a_v); + for ( size_t i = 0; i < af->n_args; i++ ) { + if ( ASRUtils::is_array(ASRUtils::expr_type(af->m_args[i])) ) { + a_v = af->m_args[i]; + if ( ASR::is_a(*a_v)) { + a_v = ASR::down_cast(a_v)->m_arg; + } + break; + } + } } else if( is_binop_expr(a_v) && for_type ) { if( ASR::is_a(*extract_member_from_binop(a_v, 1)) ) { return make_ArraySize_t_util(al, a_loc, extract_member_from_binop(a_v, 1), a_dim, a_type, a_value, for_type); From 88becb78bb0cb7b3f9ffa9d05b5c607d241dbd3a Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 11 Nov 2024 19:48:35 +0530 Subject: [PATCH 2/2] test: add and register --- integration_tests/CMakeLists.txt | 1 + integration_tests/arrays_57.f90 | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 integration_tests/arrays_57.f90 diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index f17af6b2be..db4b34b78e 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -522,6 +522,7 @@ RUN(NAME arrays_55 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc) # TODO: the below test case doesn't work unless "EXPERIMENTAL SIMPLIFIER" # is enabled i.e. works on `simplifier_pass` branch # RUN(NAME arrays_56 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc) +RUN(NAME arrays_57 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc) RUN(NAME global_allocatable_01 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc) RUN(NAME global_allocatable_02 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc) RUN(NAME global_array_pointer_01 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc) diff --git a/integration_tests/arrays_57.f90 b/integration_tests/arrays_57.f90 new file mode 100644 index 0000000000..ec1c6dca9c --- /dev/null +++ b/integration_tests/arrays_57.f90 @@ -0,0 +1,21 @@ +program arrays_57 + +real :: A(2,2) = reshape([1.0,2.0,3.0,4.0], [2,2]) +call trans(A) +print *, A +if ( any(abs( A - 12.91 ) > 1e-6) ) error stop + +contains + +subroutine trans(A) +real, intent(inout) :: A(2, 2) +A = matprod(transpose(A)) +end subroutine + +function matprod(x) result(k) +real,intent(in) :: x(:,:) +real :: k(size(x, 1), size(x, 2)) +k = 12.91 +end function + +end program