Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
ticket:5054 - add an warning message about missing rooted branch and…
Browse files Browse the repository at this point in the history
… continue

Belonging to [master]:
  - OpenModelica/OpenModelica#78
  - #2586
  • Loading branch information
adrpo authored and OpenModelica-Hudson committed Aug 2, 2018
1 parent bb8f3d8 commit 4892660
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
40 changes: 24 additions & 16 deletions Compiler/NFFrontEnd/NFOCConnectionGraph.mo
Expand Up @@ -101,6 +101,7 @@ import ElementSource;
import NFTyping.ExpOrigin;
import Typing = NFTyping;
import NFPrefixes.Variability;
import Error;

type Edge = tuple<ComponentRef,ComponentRef> "an edge is a tuple with two component references";
type Edges = list<Edge> "A list of edges";
Expand Down Expand Up @@ -1283,9 +1284,10 @@ algorithm
list<Expression> lst;
Call call;
Expression res, exp;
String str;

// handle rooted - with zero size array or the normal call
case (Expression.CALL(call = call as Call.TYPED_CALL(arguments = lst)), (rooted,roots,graph))
case (Expression.CALL(call = call as Call.TYPED_CALL(arguments = lst as {_})), (rooted,roots,graph))
equation
true =
Absyn.pathEqual(Function.name(call.fn), Absyn.IDENT("rooted")) or
Expand All @@ -1300,22 +1302,28 @@ algorithm
then Expression.BOOLEAN(false);
// normal call
case {Expression.CREF(cref = cref)}
equation
algorithm
// find partner in branches
branches = getBranches(graph);
cref1 = getEdge(cref,branches);
// print("- NFOCConnectionGraph.evalConnectionsOperatorsHelper: Found Branche Partner " +
// ComponentRef.toString(cref) + ", " + ComponentRef.toString(cref1) + "\n");
if Flags.isSet(Flags.CGRAPH) then
print("- NFOCConnectionGraph.evalConnectionsOperatorsHelper: Found Branche Partner " +
ComponentRef.toString(cref) + ", " + ComponentRef.toString(cref1) + "\n");
end if;
result = getRooted(cref,cref1,rooted);
//print("- NFOCConnectionGraph.evalRootedAndIsRootHelper: " +
// ComponentRef.toString(cref) + " is " + boolString(result) + " rooted\n");
if Flags.isSet(Flags.CGRAPH) then
print("- NFOCConnectionGraph.evalConnectionsOperatorsHelper: " + Expression.toString(inExp) + " = " + boolString(result) + "\n");
end if;
branches := getBranches(graph);
try
cref1 := getEdge(cref,branches);
// print("- NFOCConnectionGraph.evalConnectionsOperatorsHelper: Found Branche Partner " +
// ComponentRef.toString(cref) + ", " + ComponentRef.toString(cref1) + "\n");
if Flags.isSet(Flags.CGRAPH) then
print("- NFOCConnectionGraph.evalConnectionsOperatorsHelper: Found Branche Partner " +
ComponentRef.toString(cref) + ", " + ComponentRef.toString(cref1) + "\n");
end if;
result := getRooted(cref,cref1,rooted);
//print("- NFOCConnectionGraph.evalRootedAndIsRootHelper: " +
// ComponentRef.toString(cref) + " is " + boolString(result) + " rooted\n");
if Flags.isSet(Flags.CGRAPH) then
print("- NFOCConnectionGraph.evalConnectionsOperatorsHelper: " + Expression.toString(inExp) + " = " + boolString(result) + "\n");
end if;
else // add an error message:
str := ComponentRef.toString(cref);
Error.addMessage(Error.OCG_MISSING_BRANCH, {str, str, str});
result := false;
end try;
then
Expression.BOOLEAN(result);
end match;
Expand Down
3 changes: 3 additions & 0 deletions Compiler/Util/Error.mo
Expand Up @@ -994,6 +994,9 @@ public constant Message STATE_STATESELECT_NEVER = MESSAGE(592, SYMBOLIC(), WARNI
Util.gettext("Variable %s has attribute stateSelect=StateSelect.never, but was selected as a state"));
public constant Message FUNCTION_HIGHER_VARIABILITY_BINDING = MESSAGE(593, TRANSLATION(), WARNING(),
Util.gettext("Component ‘%s’ of variability %s has binding %s of higher variability %s."));
public constant Message OCG_MISSING_BRANCH = MESSAGE(594, TRANSLATION(), WARNING(),
Util.gettext("Connections.rooted(%s) needs exactly one statement Connections.branch(%s, B.R) involving %s but we found none in the graph. Run with -d=cgraphGraphVizFile to debug"));


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

0 comments on commit 4892660

Please sign in to comment.