diff --git a/Compiler/SimCode/SimCodeMain.mo b/Compiler/SimCode/SimCodeMain.mo index 1dbbd00ec6..27b7165f26 100644 --- a/Compiler/SimCode/SimCodeMain.mo +++ b/Compiler/SimCode/SimCodeMain.mo @@ -566,7 +566,6 @@ protected end if; res := (true,SimCodeUtil.getFunctionIndex()); else - ErrorExt.moveMessagesToParentThread(); end try; end runTplWriteFile; @@ -581,7 +580,6 @@ protected Tpl.tplCallWithFailErrorNoArg(func); res := (true,SimCodeUtil.getFunctionIndex()); else - ErrorExt.moveMessagesToParentThread(); end try; end runTpl; @@ -599,7 +597,6 @@ protected func(); res := (true,SimCodeUtil.getFunctionIndex()); else - ErrorExt.moveMessagesToParentThread(); end try; end runToStr; @@ -611,7 +608,10 @@ protected algorithm (res as (b,_)) := func(); if not b then - print(System.dladdr(func) + " failed\n"); + Error.addInternalError(System.dladdr(func) + " failed\n", sourceInfo()); + end if; + if ErrorExt.getNumMessages() > 0 then + ErrorExt.moveMessagesToParentThread(); end if; end runCodegenFunc; diff --git a/Compiler/SimCode/SimCodeUtil.mo b/Compiler/SimCode/SimCodeUtil.mo index a6bda936b6..6dd04612aa 100644 --- a/Compiler/SimCode/SimCodeUtil.mo +++ b/Compiler/SimCode/SimCodeUtil.mo @@ -399,29 +399,29 @@ algorithm if debug then execStat("simCode: createModelInfo and variables"); end if; //build labels - if(boolAnd(ifcpp,Flags.getConfigBool(Flags.LABELED_REDUCTION))) then - Flags.setConfigBool(Flags.GENERATE_LABELED_SIMCODE,true); + if(boolAnd(ifcpp,Flags.getConfigBool(Flags.LABELED_REDUCTION))) then + Flags.setConfigBool(Flags.GENERATE_LABELED_SIMCODE,true); end if; - if(ifcpp) then - if Flags.getConfigBool(Flags.GENERATE_LABELED_SIMCODE) then + if(ifcpp) then + if Flags.getConfigBool(Flags.GENERATE_LABELED_SIMCODE) then (allEquations,modelInfo) := ReduceDAE.buildLabels(allEquations,modelInfo,{},args); //Flags.set(Flags.REDUCE_DAE,true); - if debug then execStat("ReduceDAE: buildLabels"); end if; - end if; - end if; + if debug then execStat("ReduceDAE: buildLabels"); end if; + end if; + end if; tmpSimVars := modelInfo.vars; //reduce terms - if(ifcpp) then - if Flags.getConfigBool(Flags.REDUCE_TERMS) then + if(ifcpp) then + if Flags.getConfigBool(Flags.REDUCE_TERMS) then (allEquations,modelInfo) := ReduceDAE.reduceTerms(allEquations,modelInfo,args); Flags.setConfigBool(Flags.REDUCE_TERMS, false); - _:=Flags.disableDebug(Flags.REDUCE_DAE); - if debug then execStat("ReduceDAE: reduceTerms"); end if; - end if; - end if; + Flags.disableDebug(Flags.REDUCE_DAE); + if debug then execStat("ReduceDAE: reduceTerms"); end if; + end if; + end if; // external objects extObjInfo := createExtObjInfo(shared); @@ -13319,6 +13319,19 @@ algorithm case (cref, SimCode.SIMCODE(crefToSimVarHT = crefToSimVarHT) ) equation sv = BaseHashTable.get(cref, crefToSimVarHT); + sv = match sv.aliasvar + case SimCodeVar.NOALIAS() then sv; + /* The C++ runtime generates a different set of variables... */ + case _ guard Config.simCodeTarget() == "Cpp" then sv; + case SimCodeVar.ALIAS(varName=cref) + algorithm + Error.addSourceMessage(Error.COMPILER_WARNING, {getInstanceName() + " got an alias variable " + ComponentReference.printComponentRefStr(inCref) + " to " + ComponentReference.printComponentRefStr(cref) + ", but before code generation these should have been removed"}, sv.source.info); + then cref2simvar(cref, simCode); + case SimCodeVar.NEGATEDALIAS(varName=cref) + algorithm + Error.addSourceMessage(Error.INTERNAL_ERROR, {getInstanceName() + " got a negated alias variable " + ComponentReference.printComponentRefStr(inCref) + " to " + ComponentReference.printComponentRefStr(cref) + ", but before code generation these should have been removed"}, sv.source.info); + then fail(); + end match; then sv; case (_, _)