Skip to content

Commit

Permalink
Fix bug #2505
Browse files Browse the repository at this point in the history
- remove zero sized loops from the DAE
- added test testsuite/simulation/modelica/arrays/ZeroSizeLoop.mos
- updated test testsuite/flattening/modelica/arrays/EmptyArraySubscript.mo


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@18612 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Jan 9, 2014
1 parent 64a283d commit 5ea6477
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions Compiler/FrontEnd/InstSection.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2080,7 +2080,7 @@ protected function instForStatement_dispatch
output list<DAE.Statement> outStatements "for statements can produce more statements than one by unrolling";
algorithm
(outCache,outStatements) :=
match(inCache,inEnv,inIH,inPrefix,ci_state,iterator,range,inForBody,info,inSource,inInitial,inBool,unrollForLoops)
matchcontinue(inCache,inEnv,inIH,inPrefix,ci_state,iterator,range,inForBody,info,inSource,inInitial,inBool,unrollForLoops)
local
Env.Cache cache;
list<Env.Frame> env,env_1;
Expand All @@ -2101,6 +2101,19 @@ algorithm
InstanceHierarchy ih;
DAE.ElementSource source;

// empty range, i.e. 1:0, return nothing!
case (cache,env,ih,pre,_,i,SOME(e),sl,_,source,initial_,impl,_)
equation
(cache,e_1,(prop as DAE.PROP(t,cnst)),_) = Static.elabExp(cache, env, e, impl, NONE(), true, pre, info);
(cache, e_1) = Ceval.cevalRangeIfConstant(cache, env, e_1, prop, impl, info);

// only do this if the range is parameter or constant!
true = listMember(cnst, {DAE.C_CONST(), DAE.C_PARAM()});
// is empty range array?
(cache, Values.ARRAY(valueLst = {}), _) = Ceval.ceval(cache, env, e_1, impl, NONE(), Absyn.MSG(info), 0);
then
(cache,{});

// one iterator
case (cache,env,ih,pre,_,i,SOME(e),sl,_,source,initial_,impl,_)
equation
Expand Down Expand Up @@ -2133,7 +2146,7 @@ algorithm
then
(cache,{stmt});

end match;
end matchcontinue;
end instForStatement_dispatch;

protected function instComplexEquation "instantiate a comlex equation, i.e. c = Complex(1.0,-1.0) when Complex is a record"
Expand Down Expand Up @@ -2871,7 +2884,7 @@ algorithm
case (cache,_,_,_,_,_,Values.ARRAY(valueLst = {}),_,_,_,_,_)
then (cache,{});

/* array equation, use instAlgorithms */
// array equation, use instAlgorithms
case (cache,env,ih,pre,_,i,Values.ARRAY(valueLst = (fst :: rest), dimLst = dim :: dims),
algs,_,initial_,impl,_)
equation
Expand Down

0 comments on commit 5ea6477

Please sign in to comment.