Skip to content

Commit

Permalink
- better error message for sqrt
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@13747 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Nov 1, 2012
1 parent bbc0ebf commit cb7dbf9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions Compiler/BackEnd/BackendDAECreate.mo
Expand Up @@ -1714,8 +1714,6 @@ algorithm
DAE.Exp target, source;
list<DAE.Exp> rest_targets, rest_sources;
list<BackendDAE.Equation> eqns;
DAE.Type ty;
Integer size;
DAE.ElementSource eq_source;
case ({}, {}, _, _,_) then iEqns;
// case for complex equations, array equations and equations
Expand All @@ -1725,7 +1723,7 @@ algorithm
(source,eq_source,_) = Inline.inlineExp(source, (SOME(funcs),{DAE.NORM_INLINE()}), eq_source);
eqns = lowerextendedRecordEqn(target,source,eq_source,funcs,iEqns);
then
lowerTupleAssignment(rest_targets, rest_sources, eq_source, funcs,eqns);
lowerTupleAssignment(rest_targets, rest_sources, inEq_source, funcs,eqns);
end match;
end lowerTupleAssignment;

Expand Down
4 changes: 2 additions & 2 deletions Compiler/BackEnd/SimCodeUtil.mo
Expand Up @@ -3096,10 +3096,10 @@ algorithm
DAE.Algorithm addAssert;
list<DAE.Algorithm> inasserts;

// special case for time, it is never part of the equation system
// sqrt
case (((e as DAE.CALL(path=Absyn.IDENT(name="sqrt"), expLst={e1})),inasserts))
equation
estr = "Model error: Argument of sqrt should be >= 0";
estr = "Model error: Argument of sqrt(" +& ExpressionDump.printExpStr(e1) +& ") should be >= 0";
addAssert = DAE.ALGORITHM_STMTS({DAE.STMT_ASSERT(DAE.RELATION(e1,DAE.GREATEREQ(DAE.T_REAL_DEFAULT),DAE.RCONST(0.0),-1,NONE()),DAE.SCONST(estr),DAE.ASSERTIONLEVEL_ERROR,DAE.emptyElementSource)});
then ((e, addAssert::inasserts));

Expand Down
2 changes: 1 addition & 1 deletion Compiler/Template/CodegenC.tpl
Expand Up @@ -6625,7 +6625,7 @@ template daeExpCall(Exp call, Context context, Text &preExp /*BUFP*/, Text &varD
'sqrt(<%argStr%>)'
else
let ass = '(<%argStr%> >= 0.0)'
let retPre = assertCommonVar(ass,createDAEString("Model error: Argument of sqrt should be >= 0"), context, &varDecls, dummyInfo)
let retPre = assertCommonVar(ass,createDAEString('Model error: Argument of sqrt(<%printExpStr(e1)%>) should be >= 0'), context, &varDecls, dummyInfo)
let &preExp += '<%retPre%>'
'sqrt(<%argStr%>)')

Expand Down

0 comments on commit cb7dbf9

Please sign in to comment.