Skip to content

Commit

Permalink
[CodegenC] do not check for zero increment if it is constant +1 or -1
Browse files Browse the repository at this point in the history
Belonging to [master]:
  - OpenModelica/OMCompiler#2049
  • Loading branch information
hkiel authored and OpenModelica-Hudson committed Jan 11, 2018
1 parent cbe247e commit f7a2136
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Compiler/Template/CodegenCFunctions.tpl
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

0 comments on commit f7a2136

Please sign in to comment.