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

[CodegenC] do not check for zero increment if it is constant +1 or -1 #2049

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions Compiler/Template/CodegenCFunctions.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3008,15 +3008,15 @@ case RANGE(__) then
case FUNCTION_CONTEXT(__)
case PARALLEL_FUNCTION_CONTEXT(__) then ''
else '_withEquationIndexes'
let stepCheck = match stepValue
case "1"
case "((modelica_integer) 1)"
case "((modelica_integer) -1)" then ''
else 'if(!<%stepVar%>) {<%\n%> FILE_INFO info = omc_dummyFileInfo; omc_assert<%AddionalFuncName%>(threadData, info, <%eqnsindx%>"assertion range step != 0 failed");<%\n%>} else '
<<
<%preExp%>
<%startVar%> = <%startValue%>; <%stepVar%> = <%stepValue%>; <%stopVar%> = <%stopValue%>;
if(!<%stepVar%>)
{
FILE_INFO info = omc_dummyFileInfo;
omc_assert<%AddionalFuncName%>(threadData, info, <%eqnsindx%>"assertion range step != 0 failed");
}
else if(!(((<%stepVar%> > 0) && (<%startVar%> > <%stopVar%>)) || ((<%stepVar%> < 0) && (<%startVar%> < <%stopVar%>))))
<%stepCheck%>if(!(((<%stepVar%> > 0) && (<%startVar%> > <%stopVar%>)) || ((<%stepVar%> < 0) && (<%startVar%> < <%stopVar%>))))
{
<%type%> <%iterName%>;
for(<%iterName%> = <%startValue%>; in_range_<%shortType%>(<%iterName%>, <%startVar%>, <%stopVar%>); <%iterName%> += <%stepVar%>)
Expand Down