Skip to content

Commit 3d1405e

Browse files
committed
Add line numbers to error-messages from RemoveSimpleEquations
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@22608 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 65a1588 commit 3d1405e

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

Compiler/BackEnd/RemoveSimpleEquations.mo

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ algorithm
11901190
DAE.ComponentRef cr1, cr2;
11911191
list<Integer> colum;
11921192
DAE.Exp crexp1, crexp2;
1193-
String msg;
1193+
String lhs, rhs;
11941194
DAE.ElementSource source;
11951195

11961196
case (BackendDAE.VAR(varName=cr1), _, _, false, BackendDAE.VAR(varName=cr2), _, _, false, _, _, _, _)
@@ -1222,9 +1222,9 @@ algorithm
12221222
crexp2 = Expression.crefExp(cr2);
12231223
crexp1 = negateExpression(negatedCr1, crexp1, crexp1, " generateSimpleContainter ");
12241224
crexp2 = negateExpression(negatedCr2, crexp2, crexp2, " generateSimpleContainter ");
1225-
msg = "Found Equation without time dependent variables ";
1226-
msg = msg +& ExpressionDump.printExpStr(crexp1) +& " = " +& ExpressionDump.printExpStr(crexp2) +& "\n";
1227-
Error.addMessage(Error.INTERNAL_ERROR, {msg});
1225+
lhs = ExpressionDump.printExpStr(crexp1);
1226+
rhs = ExpressionDump.printExpStr(crexp2);
1227+
Error.addSourceMessage(Error.EQ_WITHOUT_TIME_DEP_VARS, {lhs, rhs}, DAEUtil.getElementSourceFileInfo(source));
12281228
then
12291229
fail();
12301230

@@ -2541,7 +2541,7 @@ algorithm
25412541
DAE.ElementSource source;
25422542
DAE.Exp crexp, exp1;
25432543
Option<DAE.Exp> dexp, derReplacement;
2544-
String msg;
2544+
String lhs,rhs;
25452545
VarSetAttributes vsattr;
25462546
BackendDAE.EquationAttributes eqAttr;
25472547

@@ -2575,27 +2575,26 @@ algorithm
25752575
negated = boolOr(negatedCr1, negatedCr2);
25762576
crexp = Expression.crefExp(cr);
25772577
crexp = negateExpression(negated, crexp, crexp, " PARAMETERLAIAS ");
2578-
msg = "Found Equation without time dependent variables ";
2579-
msg = msg +& ExpressionDump.printExpStr(exp) +& " = " +& ExpressionDump.printExpStr(crexp) +& "\n";
2580-
Error.addMessage(Error.INTERNAL_ERROR, {msg});
2578+
lhs = ExpressionDump.printExpStr(exp);
2579+
rhs = ExpressionDump.printExpStr(crexp);
2580+
Error.addSourceMessage(Error.EQ_WITHOUT_TIME_DEP_VARS, {lhs, rhs}, DAEUtil.getElementSourceFileInfo(source));
25812581
then
25822582
fail();
25832583

2584-
case (TIMEALIAS(negatedCr2=_), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _)
2584+
case (TIMEALIAS(eqnAttributes=(source,_)), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _)
25852585
equation
25862586
// report error
2587-
msg = "Found Equation without time dependent variables ";
2588-
msg = msg +& " time = " +& ExpressionDump.printExpStr(exp) +& "\n";
2589-
Error.addMessage(Error.INTERNAL_ERROR, {msg});
2587+
rhs = ExpressionDump.printExpStr(exp);
2588+
Error.addSourceMessage(Error.EQ_WITHOUT_TIME_DEP_VARS, {"time", rhs}, DAEUtil.getElementSourceFileInfo(source));
25902589
then
25912590
fail();
25922591

2593-
case (TIMEINDEPENTVAR( exp=exp1), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _)
2592+
case (TIMEINDEPENTVAR(exp=exp1, eqnAttributes=(source,_)), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _)
25942593
equation
25952594
// report error
2596-
msg = "Found Equation without time dependent variables ";
2597-
msg = msg +& ExpressionDump.printExpStr(exp) +& " = " +& ExpressionDump.printExpStr(exp1) +& "\n";
2598-
Error.addMessage(Error.INTERNAL_ERROR, {msg});
2595+
lhs = ExpressionDump.printExpStr(exp);
2596+
rhs = ExpressionDump.printExpStr(exp1);
2597+
Error.addSourceMessage(Error.EQ_WITHOUT_TIME_DEP_VARS, {lhs, rhs}, DAEUtil.getElementSourceFileInfo(source));
25992598
then
26002599
fail();
26012600

Compiler/Util/Error.mo

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,8 @@ public constant Message CONNECT_ARRAY_SIZE_ZERO = MESSAGE(548, TRANSLATION(), WA
760760
Util.gettext("Ignoring connection of array components having size zero: %s and %s."));
761761
public constant Message ILLEGAL_RECORD_COMPONENT = MESSAGE(549, TRANSLATION(), WARNING(),
762762
Util.gettext("Ignoring record component:\n%swhen building record the constructor. Records are allowed to contain only components of basic types, arrays of basic types or other records."));
763+
public constant Message EQ_WITHOUT_TIME_DEP_VARS = MESSAGE(550, SYMBOLIC(), ERROR(),
764+
Util.gettext("Found equation without time-dependent variables: %s = %s"));
763765

764766
public constant Message MATCH_SHADOWING = MESSAGE(5001, TRANSLATION(), ERROR(),
765767
Util.gettext("Local variable '%s' shadows another variable."));

0 commit comments

Comments
 (0)