Skip to content

Commit 5eb8e60

Browse files
author
x02lucpo
committed
changed implementation of Static.elabBuiltinSum to handle also sum(3.0)
this generates an warning git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2416 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent ae53bfe commit 5eb8e60

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Compiler/Error.mo

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ public constant ErrorID ERROR_FLATTENING=88;
270270

271271
public constant ErrorID UNBOUND_PARAMETER_WARNING=500;
272272

273+
public constant ErrorID BUILTIN_FUNCTION_SUM_HAS_SCALAR_PARAMETER=501;
274+
273275
public constant ErrorID INDEX_REDUCTION_NOTIFICATION=1000;
274276

275277
protected constant list<tuple<Integer, MessageType, Severity, String>> errorTable={(SYNTAX_ERROR,SYNTAX(),ERROR(),"Syntax error near: %s"),
@@ -446,6 +448,8 @@ protected constant list<tuple<Integer, MessageType, Severity, String>> errorTabl
446448
"Error occured while flattening model %s"),
447449
(UNBOUND_PARAMETER_WARNING,TRANSLATION(),WARNING(),
448450
"Warning, parameter %s has no value."),
451+
(BUILTIN_FUNCTION_SUM_HAS_SCALAR_PARAMETER(),TRANSLATION(),WARNING(),
452+
"Warning, function \"sum\" has scalar as parameter. Parameter: \"%s\""),
449453
(INDEX_REDUCTION_NOTIFICATION,SYMBOLIC(),NOTIFICATION(),
450454
"Notification, differentiated equation %s to %s for index reduction.")};
451455

Compiler/Static.mo

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,6 +2200,22 @@ algorithm
22002200
list<Env.Frame> env;
22012201
Absyn.Exp arrexp;
22022202
Boolean impl;
2203+
case (env,{arrexp},impl) /* impl */
2204+
local String str;
2205+
equation
2206+
(exp_1,Types.PROP((Types.T_INTEGER({}),_),c),_) = elabExp(env, arrexp, impl, NONE);
2207+
str = Dump.printExpStr(arrexp);
2208+
Error.addMessage(Error.BUILTIN_FUNCTION_SUM_HAS_SCALAR_PARAMETER, {str});
2209+
then
2210+
(exp_1,Types.PROP((Types.T_INTEGER({}),NONE),c));
2211+
case (env,{arrexp},impl) /* impl */
2212+
local String str;
2213+
equation
2214+
(exp_1,Types.PROP((Types.T_REAL({}),_),c),_) = elabExp(env, arrexp, impl, NONE);
2215+
str = Dump.printExpStr(arrexp);
2216+
Error.addMessage(Error.BUILTIN_FUNCTION_SUM_HAS_SCALAR_PARAMETER, {str});
2217+
then
2218+
(exp_1,Types.PROP((Types.T_REAL({}),NONE),c));
22032219
case (env,{arrexp},impl) /* impl */
22042220
equation
22052221
(exp_1,Types.PROP((Types.T_ARRAY(dim,tp),_),c),_) = elabExp(env, arrexp, impl, NONE);

0 commit comments

Comments
 (0)