Skip to content

Commit 9295cd5

Browse files
committed
Bug fixes for supporting array indices in c_p_pointer and void* in return types
1 parent a9a026f commit 9295cd5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/libasr/codegen/asr_to_llvm.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,10 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
12231223
std::vector<llvm::Value*> indices;
12241224
for( size_t r = 0; r < x.n_args; r++ ) {
12251225
ASR::array_index_t curr_idx = x.m_args[r];
1226+
uint64_t ptr_loads_copy = ptr_loads;
1227+
ptr_loads = 2;
12261228
this->visit_expr_wrapper(curr_idx.m_right, true);
1229+
ptr_loads = ptr_loads_copy;
12271230
indices.push_back(tmp);
12281231
}
12291232
if (v->m_type->type == ASR::ttypeType::Pointer) {
@@ -2376,6 +2379,9 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
23762379
case (ASR::ttypeType::Logical) :
23772380
return_type = llvm::Type::getInt1Ty(context);
23782381
break;
2382+
case (ASR::ttypeType::CPtr) :
2383+
return_type = llvm::Type::getVoidTy(context)->getPointerTo();
2384+
break;
23792385
case (ASR::ttypeType::Derived) :
23802386
throw CodeGenError("Derived return type not implemented yet");
23812387
break;

0 commit comments

Comments
 (0)