Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix a bug in Const[int] #2514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ RUN(NAME array_02 LABELS cpython wasm c)
RUN(NAME array_03 LABELS cpython llvm c)
RUN(NAME array_04 LABELS cpython llvm c)
RUN(NAME array_05 LABELS cpython llvm c)
RUN(NAME array_06 LABELS cpython llvm)
RUN(NAME bindc_01 LABELS cpython llvm c)
RUN(NAME bindc_02 LABELS cpython llvm c)
RUN(NAME bindc_04 LABELS llvm c NOFAST)
Expand Down
19 changes: 19 additions & 0 deletions integration_tests/array_06.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from numpy import empty, int16
from lpython import i16, i32, Const

def spot_print_lpython_array(a: i16[:,:]) -> None:
print(a)

def main() -> i32:
n : Const[i32] = 15
m : Const[i32] = 3
Anm: i16[n, m] = empty((n,m), dtype=int16)
i: i32; j: i32
for i in range(n):
for j in range(m):
Anm[i,j] = i16(5)
spot_print_lpython_array(Anm)
return 0

if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion src/libasr/codegen/asr_to_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7946,7 +7946,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
// there might be a bug below.
llvm::Type *target_type = nullptr;
bool character_bindc = false;
ASR::ttype_t* arg_type_ = ASRUtils::type_get_past_array(arg_type);
ASR::ttype_t* arg_type_ = ASRUtils::type_get_past_const(ASRUtils::type_get_past_array(arg_type));
switch (arg_type_->type) {
case (ASR::ttypeType::Integer) : {
int a_kind = down_cast<ASR::Integer_t>(arg_type_)->m_kind;
Expand Down