Skip to content

Commit 5569d74

Browse files
authored
Merge pull request #2329 from Shaikh-Ubaid/changes_from_lfortran
C: Fix passing array elements as reference
2 parents 0a5d89b + 5253174 commit 5569d74

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/libasr/codegen/asr_to_c_cpp.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,14 @@ PyMODINIT_FUNC PyInit_lpython_module_)" + fn_name + R"((void) {
10721072
} else {
10731073
args += src;
10741074
}
1075+
} else if (ASR::is_a<ASR::ArrayItem_t>(*m_args[i].m_value)) {
1076+
ASR::Variable_t* param = ASRUtils::EXPR2VAR(f->m_args[i]);
1077+
if (param->m_intent == ASRUtils::intent_inout
1078+
|| param->m_intent == ASRUtils::intent_out || ASR::is_a<ASR::Struct_t>(*type)) {
1079+
args += "&" + src;
1080+
} else {
1081+
args += src;
1082+
}
10751083
} else {
10761084
if( ASR::is_a<ASR::Struct_t>(*type) ) {
10771085
args += "&" + src;

0 commit comments

Comments
 (0)