From 2a9636483ab3701b7ca744805cb2b21d56a2a99c Mon Sep 17 00:00:00 2001 From: perost Date: Thu, 25 Mar 2021 17:12:15 +0100 Subject: [PATCH] Fix code generation for boolean subscripts (#7326) - Cast boolean subscripts to _index_t, otherwise they're too small for va_arg to work properly. --- .CI/compliance.flaky | 1 - OMCompiler/Compiler/Template/CodegenCFunctions.tpl | 3 ++- OMCompiler/Compiler/Template/CodegenUtil.tpl | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.CI/compliance.flaky b/.CI/compliance.flaky index 302e823209d..3ce20b150b3 100644 --- a/.CI/compliance.flaky +++ b/.CI/compliance.flaky @@ -1,2 +1 @@ -ModelicaCompliance.Algorithms.For.ImplicitMultiMixedIterator ModelicaCompliance.Functions.Calls.Vectorization.VectorizationMultiInputIllegal diff --git a/OMCompiler/Compiler/Template/CodegenCFunctions.tpl b/OMCompiler/Compiler/Template/CodegenCFunctions.tpl index 3b0513e0db2..30ba5db98f4 100644 --- a/OMCompiler/Compiler/Template/CodegenCFunctions.tpl +++ b/OMCompiler/Compiler/Template/CodegenCFunctions.tpl @@ -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 "" @@ -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; diff --git a/OMCompiler/Compiler/Template/CodegenUtil.tpl b/OMCompiler/Compiler/Template/CodegenUtil.tpl index f3ff947e6db..5bc1c304615 100644 --- a/OMCompiler/Compiler/Template/CodegenUtil.tpl +++ b/OMCompiler/Compiler/Template/CodegenUtil.tpl @@ -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