Skip to content

Commit a1772cc

Browse files
committed
Fix #2566 in the FrontEnd
- report parameter T p(start = value, fixed = true) and use the start value. git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19014 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent bca2a79 commit a1772cc

File tree

4 files changed

+48
-4
lines changed

4 files changed

+48
-4
lines changed

Compiler/FrontEnd/InstBinding.mo

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ algorithm
621621
DAE.Exp e_1,e;
622622
Option<Values.Value> e_val;
623623
DAE.Const c;
624-
String e_tp_str,tp_str,e_str,e_str_1,str;
624+
String e_tp_str,tp_str,e_str,e_str_1,str,s,pre_str;
625625
Env.Cache cache;
626626
DAE.Properties prop;
627627
DAE.Binding binding;
@@ -655,9 +655,19 @@ algorithm
655655
// and maybe a lot others.
656656
case (cache,_,SCode.ATTR(variability = SCode.PARAM()),DAE.MOD(eqModOption = NONE()),tp,_,_,_)
657657
equation
658+
true = Types.getFixedVarAttributeParameterOrConstant(tp);
659+
// this always succeeds but return NOMOD if there is no (start = x)
658660
startValueModification = Mod.lookupCompModification(inMod, "start");
661+
// make sure is NOT a DAE.NOMOD!
662+
false = Mod.isEmptyMod(startValueModification);
659663
(cache,binding) = makeBinding(cache,inEnv,inAttributes,startValueModification,inType,inPrefix,componentName,inInfo);
660664
binding = DAEUtil.setBindingSource(binding, DAE.BINDING_FROM_START_VALUE());
665+
666+
s = componentName;
667+
pre_str = PrefixUtil.printPrefixStr2(inPrefix);
668+
s = pre_str +& s;
669+
str = DAEUtil.printBindingExpStr(binding);
670+
Error.addSourceMessage(Error.UNBOUND_PARAMETER_WITH_START_VALUE_WARNING, {s,str}, inInfo);
661671
then
662672
(cache,binding);
663673

Compiler/FrontEnd/Mod.mo

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3392,5 +3392,19 @@ algorithm
33923392
end match;
33933393
end addEachToSubsIfNeeded;
33943394

3395+
public function isEmptyMod
3396+
"@author: adrpo
3397+
returns true if this is an empty modifier"
3398+
input DAE.Mod inMod;
3399+
output Boolean isEmpty;
3400+
algorithm
3401+
isEmpty := match(inMod)
3402+
case (DAE.NOMOD()) then true;
3403+
// That's a NOMOD() if I ever saw one...
3404+
case (DAE.MOD(subModLst={},eqModOption=NONE())) then true;
3405+
else false;
3406+
end match;
3407+
end isEmptyMod;
3408+
33953409
end Mod;
33963410

Compiler/FrontEnd/Static.mo

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10684,7 +10684,7 @@ algorithm
1068410684
// adrpo: report a warning if the binding came from a start value!
1068510685
case (cache,env,cr,attr as DAE.ATTR(variability = SCode.PARAM()),_,_,tt,bind as DAE.EQBOUND(source = DAE.BINDING_FROM_START_VALUE()),doVect,_,_,_,_)
1068610686
equation
10687-
true = Types.getFixedVarAttribute(tt);
10687+
true = Types.getFixedVarAttributeParameterOrConstant(tt);
1068810688
s = ComponentReference.printComponentRefStr(cr);
1068910689
pre_str = PrefixUtil.printPrefixStr2(inPrefix);
1069010690
s = pre_str +& s;
@@ -10940,7 +10940,7 @@ algorithm
1094010940
case (cache,env,cr,attr as DAE.ATTR(variability = SCode.PARAM()),_,NONE()/* not foriter*/,tt,DAE.UNBOUND(),
1094110941
doVect,InstTypes.SPLICEDEXPDATA(sexp,idTp),_,_,_)
1094210942
equation
10943-
false = Types.getFixedVarAttribute(tt);
10943+
false = Types.getFixedVarAttributeParameterOrConstant(tt);
1094410944
expTy = Types.simplifyType(tt);
1094510945
expIdTy = Types.simplifyType(idTp);
1094610946
cr_1 = fillCrefSubscripts(cr, tt);
@@ -11925,7 +11925,7 @@ algorithm
1192511925
equation
1192611926
true = Types.isParameter(inConst);
1192711927
ty = Types.getPropType(prop);
11928-
false = Types.getFixedVarAttribute(ty);
11928+
false = Types.getFixedVarAttributeParameterOrConstant(ty);
1192911929
then
1193011930
(inCache, inSubscript);
1193111931

Compiler/FrontEnd/Types.mo

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2841,6 +2841,26 @@ algorithm
28412841
vl_1 := getVars(vl, isOutputVar);
28422842
end getOutputVars;
28432843

2844+
public function getFixedVarAttributeParameterOrConstant
2845+
"Returns the value of the fixed attribute of a builtin type.
2846+
If there is no fixed in the tyep it returns true"
2847+
input DAE.Type tp;
2848+
output Boolean fix;
2849+
algorithm
2850+
fix := matchcontinue(tp)
2851+
// there is a fixed!
2852+
case (_)
2853+
equation
2854+
fix = getFixedVarAttribute(tp);
2855+
then
2856+
fix;
2857+
2858+
// there is no fixed!
2859+
case (_) then true;
2860+
2861+
end matchcontinue;
2862+
end getFixedVarAttributeParameterOrConstant;
2863+
28442864
public function getFixedVarAttribute "Returns the value of the fixed attribute of a builtin type"
28452865
input DAE.Type tp;
28462866
output Boolean fixed;

0 commit comments

Comments
 (0)