kind: Compile time
Closes #325 (closed).
Merge request reports
Activity
802 802 case 1: // Single argument intrinsics 803 if (var_name=="kind") { 804 int64_t kind_num = 4; // Default 805 ASR::expr_t* kind_expr = args[0]; 806 ASR::expr_t* symbolic_value = kind_expr; // == 0.d0 for kind(0.d0) 807 ASR::ttype_t* kind_type = LFortran::ASRUtils::expr_type(kind_expr); 808 // TODO: Check that the expression reduces to a valid constant expression (10.1.12) 809 switch( kind_expr->type ) { 810 case ASR::exprType::ConstantInteger: { 811 // When this is a constant value, directly assign it to the numeric 812 kind_num = ASR::down_cast<ASR::ConstantInteger_t>(kind_expr)->m_n; 813 if (kind_num <= 4) { 814 kind_num = 4; 815 } else { 816 kind_num = 8; 817 } I don't think this logic is correct. The
kind(0.d0)
does not look at the value of0.d0
but rather its type. Your implementation would return 13 forkind(13)
. Rather, it should return4
, since the integer kind of 13 is 32 bit (4). Try to copy the logic from here:Here are some examples:
kind(5) = 4 kind(5_4) = 4 kind(5_8) = 8 kind(0.d0) = 8 kind(0.0) = 4 kind(5._4) = 4 kind(5._8) = 8 kind(.true.) = 4
For value, it should return 4 and 8 (which is what
kind_num
is used for); but isn'tsymbolic_value
supposed to hold the expression (13
forkind(13)
); based on #325 (comment 645680051)?Edited by Rohit Goswamichanged this line in version 6 of the diff
added 2 commits
added 12 commits
-
515d305e...001e9446 - 10 commits from branch
lfortran:master
- b278c65b - kind: Start skeleton [skip ci]
- 56359067 - tests: Add kind [skip ci]
-
515d305e...001e9446 - 10 commits from branch
added 1 commit
- fe0d3706 - kind: Clean and rework to mimic real [skip ci]
added 9 commits
-
fe0d3706...4033a2b0 - 7 commits from branch
lfortran:master
- dd45187e - kind: Start skeleton [skip ci]
- faafde23 - kind: Clean and rework to mimic real [skip ci]
-
fe0d3706...4033a2b0 - 7 commits from branch
added 8 commits
-
7cb66587 - 1 commit from branch
lfortran:master
- 76e9fb27 - kind: Start skeleton [skip ci]
- aad7b125 - kind: Clean and rework to mimic real [skip ci]
- d004621e - cmake: Run gfortran for kind [skip ci]
- d199008a - kind: Use extract_kind for variables
- cde3110d - docs: Be modern
- 225b2012 - tests: Try all cases [skip ci]
- 194e195a - symboltable: Kill extraneous header
Toggle commit list-
7cb66587 - 1 commit from branch
@certik this is ready now.
- Resolved by Rohit Goswami
added 2 commits
enabled automatic add to merge train when the pipeline for e3d9a53c succeeds
mentioned in commit 7eda18ee