Skip to content

Commit

Permalink
- Added testcase for checking a recursion limit of any class (maximum…
Browse files Browse the repository at this point in the history
… depth=100)

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@11747 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Apr 13, 2012
1 parent ac26004 commit a2df03b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Compiler/FrontEnd/Inst.mo
Expand Up @@ -971,8 +971,8 @@ algorithm
DAE.Mod mod;
Prefix.Prefix pre;
Connect.Sets csets;
String n;
Boolean impl,callscope_1,isFn,notIsPartial,isPartialFn;
String n,scopeName;
Boolean impl,callscope_1,isFn,notIsPartial,isPartialFn,recursionDepthReached;
SCode.Partial partialPrefix;
SCode.Encapsulated encflag;
ClassInf.State ci_state,ci_state_1;
Expand Down Expand Up @@ -1011,9 +1011,12 @@ algorithm
* Then generate equations from connects.
*/
case (cache,env,ih,store,mod,pre,
(c as SCode.CLASS(name = n,encapsulatedPrefix = encflag,restriction = r, partialPrefix = partialPrefix)),
(c as SCode.CLASS(name = n,encapsulatedPrefix = encflag,restriction = r, partialPrefix = partialPrefix, info = info)),
inst_dims,impl,callscope,graph,_)
equation
recursionDepthReached = listLength(env) < 100;
scopeName = Debug.bcallret1(not recursionDepthReached,Env.printEnvPathStr,env,"");
Error.assertionOrAddSourceMessage(recursionDepthReached,Error.RECURSION_DEPTH_REACHED,{scopeName},info);
//print("---- CLASS: "); print(n);print(" ----\n"); print(SCodeDump.printClassStr(c)); //Print out the input SCode class
//str = SCodeDump.printClassStr(c); print("------------------- CLASS instClass-----------------\n");print(str);print("\n===============================================\n");

Expand Down
2 changes: 2 additions & 0 deletions Compiler/Util/Error.mo
Expand Up @@ -651,6 +651,8 @@ public constant Message INST_INVALID_RESTRICTION = MESSAGE(525, TRANSLATION(), E
"Cannot instantiate %s due to restriction %s.");
public constant Message INST_NON_LOADED = MESSAGE(525, TRANSLATION(), WARNING(),
"Library %s was not loaded but is marked as used by model %s.");
public constant Message RECURSION_DEPTH_REACHED = MESSAGE(526, TRANSLATION(), ERROR(),
"The maximum recursion depth was reached, probably due to mutual recursion. The current scope: %s.");

public constant Message INDEX_REDUCTION_NOTIFICATION = MESSAGE(1000, SYMBOLIC(), NOTIFICATION(),
"Differentiated equation %s to %s for index reduction");
Expand Down

0 comments on commit a2df03b

Please sign in to comment.