Skip to content

Commit

Permalink
Merge pull request #4785 from gxyd/associate_07_fix
Browse files Browse the repository at this point in the history
ASR->LLVM: handle association to PointerNullConstant by creating just a store
  • Loading branch information
certik authored Sep 12, 2024
2 parents 4a0a5d0 + 91cd06b commit e1524c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ RUN(NAME associate_02 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc llvm17)
RUN(NAME associate_03 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc llvm17)
RUN(NAME associate_04 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc llvm17)
RUN(NAME associate_05 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc)
# RUN(NAME associate_07 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc)
RUN(NAME associate_07 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc)
RUN(NAME associate_08 LABELS gfortran llvm)
RUN(NAME associate_09 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc llvm17)
RUN(NAME associate_10 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc)
Expand Down
9 changes: 6 additions & 3 deletions src/libasr/codegen/asr_to_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4516,12 +4516,15 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
return;
}
}
bool is_target_class = ASR::is_a<ASR::ClassType_t>(
[[maybe_unused]] bool is_target_class = ASR::is_a<ASR::ClassType_t>(
*ASRUtils::type_get_past_pointer(target_type));
bool is_value_class = ASR::is_a<ASR::ClassType_t>(
[[maybe_unused]] bool is_value_class = ASR::is_a<ASR::ClassType_t>(
*ASRUtils::type_get_past_pointer(
ASRUtils::type_get_past_allocatable(value_type)));
if( is_target_class && !is_value_class ) {

if (ASR::is_a<ASR::PointerNullConstant_t>(*x.m_value)) {
builder->CreateStore(llvm_value, llvm_target);
} else if( is_target_class && !is_value_class ) {
llvm::Value* vtab_address_ptr = llvm_utils->create_gep(llvm_target, 0);
llvm_target = llvm_utils->create_gep(llvm_target, 1);
ASR::StructType_t* struct_t = ASR::down_cast<ASR::StructType_t>(
Expand Down

0 comments on commit e1524c2

Please sign in to comment.