Skip to content

Commit

Permalink
- Print out a warning if a redeclared modifier element can't be found…
Browse files Browse the repository at this point in the history
…, instead

  of silently failing.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@13689 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Oct 29, 2012
1 parent 95d80ea commit e02d6b7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
16 changes: 16 additions & 0 deletions Compiler/FrontEnd/SCodeEnv.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,22 @@ algorithm
end match;
end getEnvPath;

public function getScopeName
"Returns the name of the innermost that has a name."
input Env inEnv;
output String outString;
algorithm
outString := match(inEnv)
local
String name;
Env rest;

case FRAME(name = SOME(name)) :: _ then name;
case _ :: rest then getScopeName(rest);

end match;
end getScopeName;

public function envPrefixOf
input Env inPrefixEnv;
input Env inEnv;
Expand Down
17 changes: 10 additions & 7 deletions Compiler/FrontEnd/SCodeFlattenRedeclare.mo
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ protected function replaceRedeclaredElementInEnv
algorithm
outEnv := matchcontinue(inRedeclare, inEnv)
local
SCode.Ident name;
SCode.Ident name, scope_name;
Item item;
Absyn.Info info;
Absyn.Path path;
Expand All @@ -671,14 +671,17 @@ algorithm
then
pushRedeclareIntoExtends(item, path, inEnv);

else
// The redeclared element could not be found, show an error.
case (SCodeEnv.PROCESSED_MODIFIER(modifier = item), _)
equation
true = Flags.isSet(Flags.FAILTRACE);
Debug.traceln("- SCodeEnv.replaceRedeclaredElementInEnv failed on " +&
SCode.elementName(SCodeEnv.getRedeclarationElement(inRedeclare)) +&
" in " +& SCodeEnv.getEnvName(inEnv));
scope_name = SCodeEnv.getScopeName(inEnv);
name = SCodeEnv.getItemName(item);
info = SCodeEnv.getItemInfo(item);
Error.addSourceMessage(Error.MISSING_MODIFIED_ELEMENT,
{name, scope_name}, info);
then
fail();
fail();

end matchcontinue;
end replaceRedeclaredElementInEnv;

Expand Down
6 changes: 3 additions & 3 deletions Compiler/Util/Error.mo
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,6 @@ public constant Message UNKNOWN_DEBUG_FLAG = MESSAGE(206, SCRIPTING(), ERROR(),
Util.gettext("Unknown debug flag %s."));
public constant Message INVALID_FLAG_TYPE = MESSAGE(207, SCRIPTING(), ERROR(),
Util.gettext("Invalid type of flag %s, expected %s but got %s"));
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 CHANGED_STD_VERSION = MESSAGE(208, SCRIPTING(), NOTIFICATION(),
Util.gettext("Modelica language version set to %s due to loading of MSL %s."));
public constant Message SIMPLIFY_FIXPOINT_MAXIMUM = MESSAGE(209, TRANSLATION(), WARNING(),
Expand All @@ -507,7 +505,7 @@ public constant Message TRANS_VIOLATION = MESSAGE(212, TRANSLATION(), ERROR(),
public constant Message INSERT_CLASS = MESSAGE(213, SCRIPTING(), ERROR(),
Util.gettext("Failed to insert class %s %s the available classes were:%s"));
public constant Message MISSING_MODIFIED_ELEMENT = MESSAGE(214, TRANSLATION(), ERROR(),
Util.gettext("Modified element %s not found in class %s\n"));
Util.gettext("Modified element %s not found in class %s."));
public constant Message INVALID_REDECLARE_IN_BASIC_TYPE = MESSAGE(215, TRANSLATION(), ERROR(),
Util.gettext("Invalid redeclaration, attributes of basic types can not be redeclared."));
public constant Message INVALID_STREAM_CONNECTOR = MESSAGE(216, TRANSLATION(), ERROR(),
Expand Down Expand Up @@ -574,6 +572,8 @@ public constant Message EXP_TYPE_MISMATCH = MESSAGE(245, TRANSLATION(), ERROR(),
Util.gettext("Expression %1 has type %3, expected type %2."));
public constant Message PACKAGE_ORDER_DUPLICATES = MESSAGE(246, TRANSLATION(), ERROR(),
Util.gettext("Found duplicate names in package.order file: %s."));
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(),
Util.gettext("Parameter %s has neither value nor start value, and is fixed during initialization (fixed=true)"));
public constant Message BUILTIN_FUNCTION_PRODUCT_HAS_SCALAR_PARAMETER = MESSAGE(502, TRANSLATION(), WARNING(),
Expand Down

0 comments on commit e02d6b7

Please sign in to comment.