Skip to content

Commit

Permalink
Fix Cpp error "size(X) not implemented" (#7602)
Browse files Browse the repository at this point in the history
This happened for two models from MSL and three models from ModelicaTest.
For example, the code generation for Modelica.Fluid.Examples.IncompressibleFluidNetwork
calls daeExpSize to a literal, unrolled array instead of a cref supported so far.
  • Loading branch information
rfranke committed Jun 23, 2021
1 parent a877ba9 commit a5ff63c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions OMCompiler/Compiler/Template/CodegenCppCommon.tpl
Expand Up @@ -1210,11 +1210,11 @@ template daeExpSize(Exp exp, Context context, Text &preExp, Text &varDecls, SimC
"Generates code for a size expression."
::=
match exp
case SIZE(exp=CREF(__), sz=SOME(dim)) then
case SIZE(sz=SOME(dim)) then
let expPart = daeExp(exp, context, &preExp, &varDecls, simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, stateDerVectorName, useFlatArrayNotation)
let dimPart = daeExp(dim, context, &preExp, &varDecls, simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, stateDerVectorName, useFlatArrayNotation)
'<%expPart%>.getDim(<%dimPart%>)'
case SIZE(exp=CREF(__)) then
case SIZE(sz=NONE()) then
let expPart = daeExp(exp, context, &preExp, &varDecls, simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, stateDerVectorName, useFlatArrayNotation)
let tmp = tempDecl("vector<size_t>", &varDecls)
let &preExp +=
Expand All @@ -1225,7 +1225,7 @@ template daeExpSize(Exp exp, Context context, Text &preExp, Text &varDecls, SimC
<%tmp%>_size(<%tmp%>_i) = (int)<%tmp%>[<%tmp%>_i-1];<%\n%>
>>
'<%tmp%>_size'
else "size(X) not implemented"
else error(sourceInfo(), ExpressionDumpTpl.dumpExp(exp,"\"") + " not implemented")
end daeExpSize;


Expand Down

0 comments on commit a5ff63c

Please sign in to comment.