Commit 35f9ff82 authored by Ondřej Čertík's avatar Ondřej Čertík
Browse files

Merge branch 'fmt6' into 'master'

Generate code for dimension properly

See merge request !566
parents 7f88301a 6f71dc8a
Pipeline #184048429 passed with stages
in 4 minutes and 39 seconds
......@@ -10,6 +10,14 @@ using LFortran::AST::BaseVisitor;
namespace LFortran {
static inline AST::Num_t* EXPR_NUM(const AST::ast_t *f)
{
LFORTRAN_ASSERT(f->type == AST::astType::expr);
AST::expr_t *t = (AST::expr_t *)f;
LFORTRAN_ASSERT(t->type == AST::exprType::Num);
return (AST::Num_t*)t;
}
namespace {
std::string op2str(const operatorType type)
......@@ -837,21 +845,25 @@ public:
}
void visit_dimension(const dimension_t &x) {
std::string r;
std::string left;
bool left_is_one=false;
if (x.m_start) {
this->visit_expr(*x.m_start);
r.append(s);
} else {
r.append("");
left = s;
if (x.m_start->type == AST::exprType::Num) {
left_is_one = (EXPR_NUM((AST::ast_t*)x.m_start)->m_n == 1);
};
}
r.append(":");
std::string right;
if (x.m_end) {
this->visit_expr(*x.m_end);
r.append(s);
right = s;
}
if (left_is_one && right != "") {
s = right;
} else {
r.append("");
s = left + ":" + right;
}
s = r;
}
void visit_Attribute(const Attribute_t &x) {
......
......@@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "ast_f90-program_01-133d597.stdout",
"stdout_hash": "2f6c59567c1770bf7c1faac760132bf891f684a129757909a8aa9c6f",
"stdout_hash": "6e36132b4241096b3d2ea3ad10be36fa4cd98b95e439d3b8d954dbb9",
"stderr": null,
"stderr_hash": null,
"returncode": 0
......
......@@ -13,7 +13,7 @@ contains
subroutine rand(x)
real, intent(out) :: x
logical, save :: first=.true.
real, save :: u(1:2)
real, save :: u(2)
real :: r2
if (first) then
do
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment