Skip to content

Commit

Permalink
Handle some invalid uses-annotations, like annotation(uses(Modelica))
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23454 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Nov 19, 2014
1 parent e446dfd commit 88e1139
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Compiler/Script/Interactive.mo
Expand Up @@ -11304,18 +11304,20 @@ algorithm

case (SOME(Absyn.CLASSMOD(elementArgLst = arglst)))
then getUsesAnnotationString2(arglst);

end match;
end getUsesAnnotationString;

protected function getUsesAnnotationString2
input list<Absyn.ElementArg> eltArgs;
output list<tuple<Absyn.Path,list<String>>> strs;
algorithm
strs := matchcontinue (eltArgs)
strs := match eltArgs
local
list<Absyn.ElementArg> xs;
String name, version;
list<tuple<Absyn.Path,list<String>>> ss;
Absyn.Info info;

case ({}) then {};

Expand All @@ -11327,12 +11329,18 @@ algorithm
ss = getUsesAnnotationString2(xs);
then (Absyn.IDENT(name),{version})::ss;

case (Absyn.MODIFICATION(info = info, path = Absyn.IDENT(name = name))::xs)
equation
Error.addSourceMessage(Error.USES_MISSING_VERSION, {name}, info);
ss = getUsesAnnotationString2(xs);
then (Absyn.IDENT(name),{"default"})::ss;

case (_::xs)
equation
ss = getUsesAnnotationString2(xs);
then ss;

end matchcontinue;
end match;
end getUsesAnnotationString2;

protected function getIconAnnotation
Expand Down
3 changes: 3 additions & 0 deletions Compiler/Util/Error.mo
Expand Up @@ -674,6 +674,7 @@ public constant Message ENUM_DUPLICATES = MESSAGE(253, TRANSLATION(), ERROR(),
public constant Message RESERVED_IDENTIFIER = MESSAGE(254, TRANSLATION(), ERROR(),
Util.gettext("Identifier %s is reserved for the built-in type with the same name."));


public constant Message UNBOUND_PARAMETER_WITH_START_VALUE_WARNING = MESSAGE(499, TRANSLATION(), WARNING(),
Util.gettext("Parameter %s has no value, and is fixed during initialization (fixed=true), using available start value (start=%s) as default value."));
public constant Message UNBOUND_PARAMETER_WARNING = MESSAGE(500, TRANSLATION(), WARNING(),
Expand Down Expand Up @@ -780,6 +781,8 @@ public constant Message NOTIFY_LOAD_MODEL_FAILED = MESSAGE(556, SCRIPTING(), NOT
Util.gettext("Skipped loading package %s (%s) using MODELICAPATH %s (uses-annotation may be wrong)."));
public constant Message ROOT_USER_INTERACTIVE = MESSAGE(557, SCRIPTING(), ERROR(),
Util.gettext("You are trying to run OpenModelica as a server using the root user.\nThis is a very bad idea:\n* The socket interface does not authenticate the user.\n* OpenModelica allows execution of arbitrary commands."));
public constant Message USES_MISSING_VERSION = MESSAGE(558, SCRIPTING(), WARNING(),
Util.gettext("Uses-annotation is missing version for library %s. Assuming the tool-specific version=\"default\"."));

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

0 comments on commit 88e1139

Please sign in to comment.