Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit ec7206f

Browse files
sjoelundOpenModelica-Hudson
authored andcommitted
Only add _length variable for array reduction
The variable is unused in other reductions.
1 parent 9ce0a4a commit ec7206f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Compiler/Template/CodegenCFunctions.tpl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6489,12 +6489,13 @@ template daeExpReduction(Exp exp, Context context, Text &preExp,
64896489
omc_assert(threadData, info, "Range with a step of zero.");
64906490
}<%\n%>
64916491
>>
6492-
let &tmpVarDecls += match iter.exp case RANGE(__) then 'modelica_integer <%iter.id%>_length;<%\n%>'
6492+
let isArrayWithLength = if rangeExpStop then (match ri.path case IDENT(name="array") then "1" else "") else ""
6493+
let &tmpVarDecls += if isArrayWithLength then 'modelica_integer <%iter.id%>_length;<%\n%>'
64936494
let &rangeExpPre += match iter.exp case RANGE(__) then '<%firstIndex%> = <%iteratorName%> /* Remember the range start-value */;<%\n%>' else (if firstIndex then '<%firstIndex%> = 1;<%\n%>')
64946495
let guardCond = (match iter.guardExp case SOME(grd) then daeExp(grd, context, &guardExpPre, &tmpVarDecls, &auxFunction) else "")
64956496
let &rangeExpPre += match iter.exp case RANGE(__) then '<%iteratorName%> = (<%rangeExp%>)-<%stepVar%>;<%\n%>' /* We pre-increment the counter, so subtract the step for the first variable for ranges */
64966497
let &tmpVarDecls += '<%identType%> <%iteratorName%>;<%\n%>'
6497-
let &rangeExpPre += if rangeExpStop then
6498+
let &rangeExpPre += if isArrayWithLength then
64986499
<<
64996500
<%iter.id%>_length = ((<%stopVar%>-<%firstIndex%>)/<%stepVar%>)+1;
65006501
>>

0 commit comments

Comments
 (0)