Skip to content

Commit afffb06

Browse files
authored
Fix for #2841 (#2844)
* 2841 * Adding array tests 4,5,6 * Updated tests * More passing tests
1 parent b32fe28 commit afffb06

19 files changed

+1485
-441
lines changed

integration_tests/CMakeLists.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ endmacro(COMPILE)
418418

419419
# Test zero and non-zero exit code and assert statements
420420
RUN(NAME array_01_decl LABELS cpython llvm llvm_jit c)
421-
# RUN(NAME array_02_decl LABELS cpython llvm llvm_jit c)
421+
RUN(NAME array_02_decl LABELS cpython llvm llvm_jit c)
422422
RUN(NAME array_03_decl LABELS cpython llvm llvm_jit c)
423423
RUN(NAME variable_decl_01 LABELS cpython llvm llvm_jit c)
424424
RUN(NAME variable_decl_02 LABELS cpython llvm llvm_jit c)
@@ -431,16 +431,16 @@ RUN(NAME array_expr_04 LABELS cpython llvm llvm_jit c)
431431
RUN(NAME array_expr_06 LABELS cpython llvm llvm_jit c)
432432
RUN(NAME array_expr_07 LABELS cpython llvm llvm_jit c)
433433
RUN(NAME array_expr_08 LABELS cpython llvm llvm_jit c)
434-
# RUN(NAME array_expr_09 LABELS cpython llvm llvm_jit c)
434+
RUN(NAME array_expr_09 LABELS cpython llvm llvm_jit c)
435435
RUN(NAME array_expr_10 LABELS cpython llvm llvm_jit c)
436-
# RUN(NAME array_size_01 LABELS cpython llvm llvm_jit c)
437-
# RUN(NAME array_size_02 LABELS cpython llvm llvm_jit c)
436+
RUN(NAME array_size_01 LABELS cpython llvm llvm_jit c)
437+
RUN(NAME array_size_02 LABELS cpython llvm llvm_jit c)
438438
RUN(NAME array_01 LABELS cpython llvm llvm_jit wasm c)
439439
RUN(NAME array_02 LABELS cpython wasm c)
440440
RUN(NAME array_03 LABELS cpython llvm llvm_jit c)
441-
# RUN(NAME array_04 LABELS cpython llvm llvm_jit c)
442-
# RUN(NAME array_05 LABELS cpython llvm llvm_jit c)
443-
# RUN(NAME array_06 LABELS cpython llvm llvm_jit)
441+
RUN(NAME array_04 LABELS cpython llvm llvm_jit c)
442+
RUN(NAME array_05 LABELS cpython llvm llvm_jit c)
443+
RUN(NAME array_06 LABELS cpython llvm llvm_jit)
444444
# RUN(NAME bindc_01 LABELS cpython llvm llvm_jit c)
445445
# # RUN(NAME bindc_02 LABELS cpython llvm llvm_jit c)
446446
# RUN(NAME bindc_04 LABELS llvm llvm_jit c NOFAST)
@@ -796,9 +796,9 @@ RUN(NAME test_bit_length LABELS cpython) # renable c, FIXME: This test fails
796796

797797
RUN(NAME generics_01 LABELS cpython llvm llvm_jit) # renable c
798798
# RUN(NAME generics_02 LABELS cpython llvm llvm_jit c)
799-
# RUN(NAME generics_array_01 LABELS cpython llvm llvm_jit c)
800-
# RUN(NAME generics_array_02 LABELS cpython llvm llvm_jit c)
801-
# RUN(NAME generics_array_03 LABELS cpython llvm llvm_jit c)
799+
RUN(NAME generics_array_01 LABELS cpython llvm llvm_jit c)
800+
RUN(NAME generics_array_02 LABELS cpython llvm llvm_jit c)
801+
RUN(NAME generics_array_03 LABELS cpython llvm llvm_jit c)
802802
RUN(NAME generics_list_01 LABELS cpython llvm llvm_jit) # renable c
803803
RUN(NAME test_statistics_01 LABELS cpython llvm llvm_jit NOFAST)
804804
# RUN(NAME test_statistics_02 LABELS cpython llvm llvm_jit NOFAST REQ_PY_VER 3.10)

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8645,31 +8645,24 @@ we will have to use something else.
86458645
} else {
86468646
const Location& loc = x.base.base.loc;
86478647
ASR::ttype_t* el_type = ASRUtils::type_get_past_array(
8648-
ASRUtils::type_get_past_allocatable_pointer(type));
8649-
if( !ASRUtils::is_struct(*el_type) ) {
8650-
ASR::expr_t* zero = ASRUtils::get_constant_zero_with_given_type(al, el_type);
8651-
LCOMPILERS_ASSERT(assign_asr_target)
8652-
ASRUtils::make_ArrayBroadcast_t_util(al, x.base.base.loc, assign_asr_target, zero);
8653-
tmp = &(zero->base);
8654-
} else {
8655-
ASR::expr_t* zero = ASRUtils::get_constant_zero_with_given_type(al, int32);
8656-
LCOMPILERS_ASSERT(assign_asr_target)
8657-
size_t rank = ASRUtils::extract_n_dims_from_ttype(type);
8658-
Vec<ASR::array_index_t> array_index; array_index.reserve(al, rank);
8659-
for( size_t i = 0; i < rank; i++ ) {
8660-
ASR::array_index_t idx;
8661-
idx.loc = loc;
8662-
idx.m_left = nullptr;
8663-
idx.m_right = zero;
8664-
idx.m_step = nullptr;
8665-
array_index.push_back(al, idx);
8666-
}
8667-
ASR::expr_t* arrayitem = ASRUtils::EXPR(ASR::make_ArrayItem_t(
8668-
al, loc, assign_asr_target, array_index.p, array_index.size(),
8669-
el_type, ASR::arraystorageType::RowMajor, nullptr));
8670-
ASRUtils::make_ArrayBroadcast_t_util(al, x.base.base.loc, assign_asr_target, arrayitem);
8671-
tmp = &(arrayitem->base);
8648+
ASRUtils::type_get_past_allocatable_pointer(type));
8649+
ASR::expr_t* zero = ASRUtils::get_constant_zero_with_given_type(al, int32);
8650+
LCOMPILERS_ASSERT(assign_asr_target)
8651+
size_t rank = ASRUtils::extract_n_dims_from_ttype(type);
8652+
Vec<ASR::array_index_t> array_index; array_index.reserve(al, rank);
8653+
for( size_t i = 0; i < rank; i++ ) {
8654+
ASR::array_index_t idx;
8655+
idx.loc = loc;
8656+
idx.m_left = nullptr;
8657+
idx.m_right = zero;
8658+
idx.m_step = nullptr;
8659+
array_index.push_back(al, idx);
86728660
}
8661+
ASR::expr_t* arrayitem = ASRUtils::EXPR(ASR::make_ArrayItem_t(
8662+
al, loc, assign_asr_target, array_index.p, array_index.size(),
8663+
el_type, ASR::arraystorageType::RowMajor, nullptr));
8664+
ASRUtils::make_ArrayBroadcast_t_util(al, x.base.base.loc, assign_asr_target, arrayitem);
8665+
tmp = &(arrayitem->base);
86738666
}
86748667
return;
86758668
} else if (call_name == "c_p_pointer") {

tests/reference/asr-array_01_decl-39cf894.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"outfile": null,
77
"outfile_hash": null,
88
"stdout": "asr-array_01_decl-39cf894.stdout",
9-
"stdout_hash": "5a0243f2a25c2cfd117cd99812f153005be8c0e9d5d21838bd492aa8",
9+
"stdout_hash": "1468a63c74244b92fdc4dcebcd4b17cecf4c1c64a5fda35c3d234944",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0

0 commit comments

Comments
 (0)