Skip to content

Commit

Permalink
Fix code generation for boolean subscripts (#7326)
Browse files Browse the repository at this point in the history
- Cast boolean subscripts to _index_t, otherwise they're too small for
  va_arg to work properly.
  • Loading branch information
perost committed Mar 25, 2021
1 parent 7241f1c commit 2a96364
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 0 additions & 1 deletion .CI/compliance.flaky
@@ -1,2 +1 @@
ModelicaCompliance.Algorithms.For.ImplicitMultiMixedIterator
ModelicaCompliance.Functions.Calls.Vectorization.VectorizationMultiInputIllegal
3 changes: 2 additions & 1 deletion OMCompiler/Compiler/Template/CodegenCFunctions.tpl
Expand Up @@ -5128,6 +5128,7 @@ template subscriptToMStr(Subscript subscript)
case INDEX(__) then
match exp
case ICONST(integer=i) then i
case BCONST(bool=i) then i
case ENUM_LITERAL(index=i) then i
else
let &varDecls = buffer ""
Expand Down Expand Up @@ -7566,7 +7567,7 @@ template daeSubscriptExp(Exp exp, Context context, Text &preExp, Text &varDecls,
::=
let res = daeExp(exp,context,&preExp,&varDecls,&auxFunction)
match expTypeFromExpModelica(exp)
case "modelica_boolean" then '(<%res%>+1)'
case "modelica_boolean" then '(_index_t)(<%res%>+1)'
else res
end match
end daeSubscriptExp;
Expand Down
1 change: 1 addition & 0 deletions OMCompiler/Compiler/Template/CodegenUtil.tpl
Expand Up @@ -149,6 +149,7 @@ template subscriptStr(Subscript subscript)
::=
match subscript
case INDEX(exp=ICONST(integer=i)) then i
case INDEX(exp=BCONST(bool=i)) then i
case INDEX(exp=ENUM_LITERAL(name=n)) then dotPath(n)
case INDEX(exp=CREF()) then printExpStr(exp)
case SLICE(exp=ICONST(integer=i)) then i
Expand Down

0 comments on commit 2a96364

Please sign in to comment.