Skip to content

Commit

Permalink
Add warning for parameters with no binding
Browse files Browse the repository at this point in the history
ticket:4189
  • Loading branch information
ptaeuber authored and OpenModelica-Hudson committed Jan 5, 2017
1 parent 97e737e commit bff7053
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Compiler/BackEnd/Initialization.mo
Expand Up @@ -945,11 +945,14 @@ protected function selectParameter2 "author: lochel"
algorithm
outTpl := match (inVar, inTpl)
local
BackendDAE.Var var;
BackendDAE.Variables vars, otherVars;
BackendDAE.EquationArray eqns;
DAE.Exp bindExp, crefExp, startValue;
BackendDAE.Equation eqn;
DAE.ComponentRef cref;
String s, str;
SourceInfo info;

// parameter without binding
case (BackendDAE.VAR(varKind=BackendDAE.PARAM(), bindExp=NONE()), (vars, eqns, otherVars)) equation
Expand All @@ -960,6 +963,16 @@ algorithm
startValue = BackendVariable.varStartValue(inVar);
eqn = BackendDAE.EQUATION(crefExp, startValue, DAE.emptyElementSource, BackendDAE.EQ_ATTR_DEFAULT_INITIAL);
eqns = BackendEquation.addEquation(eqn, eqns);

if BackendVariable.varFixed(inVar) then
s = ComponentReference.printComponentRefStr(cref);
str = ExpressionDump.printExpStr(startValue);
var = BackendVariable.setVarKind(inVar, BackendDAE.VARIABLE());
var = BackendVariable.setBindExp(var, SOME(startValue));
var = BackendVariable.setVarFixed(var, true);
info = ElementSource.getElementSourceFileInfo(BackendVariable.getVarSource(var));
Error.addSourceMessage(Error.UNBOUND_PARAMETER_WITH_START_VALUE_WARNING, {s, str}, info);
end if;
then ((vars, eqns, otherVars));

// parameter with binding
Expand Down

0 comments on commit bff7053

Please sign in to comment.