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

Commit f7a2136

Browse files
hkielOpenModelica-Hudson
authored andcommitted
[CodegenC] do not check for zero increment if it is constant +1 or -1
Belonging to [master]: - #2049
1 parent cbe247e commit f7a2136

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Compiler/Template/CodegenCFunctions.tpl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3008,15 +3008,15 @@ case RANGE(__) then
30083008
case FUNCTION_CONTEXT(__)
30093009
case PARALLEL_FUNCTION_CONTEXT(__) then ''
30103010
else '_withEquationIndexes'
3011+
let stepCheck = match stepValue
3012+
case "1"
3013+
case "((modelica_integer) 1)"
3014+
case "((modelica_integer) -1)" then ''
3015+
else 'if(!<%stepVar%>) {<%\n%> FILE_INFO info = omc_dummyFileInfo; omc_assert<%AddionalFuncName%>(threadData, info, <%eqnsindx%>"assertion range step != 0 failed");<%\n%>} else '
30113016
<<
30123017
<%preExp%>
30133018
<%startVar%> = <%startValue%>; <%stepVar%> = <%stepValue%>; <%stopVar%> = <%stopValue%>;
3014-
if(!<%stepVar%>)
3015-
{
3016-
FILE_INFO info = omc_dummyFileInfo;
3017-
omc_assert<%AddionalFuncName%>(threadData, info, <%eqnsindx%>"assertion range step != 0 failed");
3018-
}
3019-
else if(!(((<%stepVar%> > 0) && (<%startVar%> > <%stopVar%>)) || ((<%stepVar%> < 0) && (<%startVar%> < <%stopVar%>))))
3019+
<%stepCheck%>if(!(((<%stepVar%> > 0) && (<%startVar%> > <%stopVar%>)) || ((<%stepVar%> < 0) && (<%startVar%> < <%stopVar%>))))
30203020
{
30213021
<%type%> <%iterName%>;
30223022
for(<%iterName%> = <%startValue%>; in_range_<%shortType%>(<%iterName%>, <%startVar%>, <%stopVar%>); <%iterName%> += <%stepVar%>)

0 commit comments

Comments
 (0)