Opened 11 years ago

Closed 11 years ago

#2708 closed defect (fixed)

wrong generated code for Q-IDENTs

Reported by: Lennart Ochel Owned by: Mahder Alemseged Gebremedhin
Priority: blocker Milestone: 1.9.1
Component: Code Generation Version: trunk
Keywords: Cc: cbrinkrolf@…

Description

Please, check the following model:

model test
  record foo
    Real 'a';
  end foo;

  foo b;

equation
  der(b.'a') = sin(b.'a');
end test;

The error Output is the following:

In file included from test.c:19:
test_functions.h:15: error: expected ':', ',', ';', '}' or '__attribute__' before 'a'
test_functions.h:21: error: expected ';', ',' or ')' before 'a'
mingw32-make: *** [test.o] Error 1
mingw32-make: *** Waiting for unfinished jobs....
In file included from test_01exo.c:19:
test_functions.h:15: error: expected ':', ',', ';', '}' or '__attribute__' before 'a'
test_functions.h:21: error: expected ';', ',' or ')' before 'a'
mingw32-make: *** [test_01exo.o] Error 1
In file included from test_functions.c:1:
test_functions.h:15: error: expected ':', ',', ';', '}' or '__attribute__' before 'a'
test_functions.h:21: error: expected ';', ',' or ')' before 'a'
test_functions.c:8: error: expected ';', ',' or ')' before 'a'
mingw32-make: *** [test_functions.o] Error 1
Compilation process exited with code 2

Change History (6)

comment:1 by Mahder Alemseged Gebremedhin, 11 years ago

Status: newaccepted

I don't know why but this went to my spam folder and just saw it. I will take a look.

comment:2 by Mahder Alemseged Gebremedhin, 11 years ago

Resolution: fixed
Status: acceptedclosed

Fixed in r20946.

comment:3 by Lennart Ochel, 11 years ago

Resolution: fixed
Status: closedreopened

Unfortuantly, there are more issues with Q-IDENTs. Just check the following example (using PNlib, trunk\testsuite\simulation\libraries\3rdParty\PNlib\PNlib.mo):

model test2
  PNlib.PC 'P1'(nIn = 0, nOut = 1, startMarks = 0.0, minMarks = 0.0, maxMarks = 1.0E9) annotation(Placement(visible = true, transformation(origin = {-80, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  PNlib.PC 'P2'(nIn = 1, nOut = 1, startMarks = 0.0, minMarks = 0.0, maxMarks = 1.0E9) annotation(Placement(visible = true, transformation(origin = {-20, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  PNlib.PC 'P3'(nIn = 1, nOut = 0, startMarks = 0.0, minMarks = 0.0, maxMarks = 1.0E9) annotation(Placement(visible = true, transformation(origin = {60, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  PNlib.TC 'T1'(nIn = 1, nOut = 1, maximumSpeed = 1, arcWeightIn = {1}, arcWeightOut = {1}) annotation(Placement(visible = true, transformation(origin = {-60, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  PNlib.TC 'T2'(nIn = 1, nOut = 1, maximumSpeed = 1, arcWeightIn = {1}, arcWeightOut = {1}) annotation(Placement(visible = true, transformation(origin = {20, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
  connect('P1'.outTransition[1], 'T1'.inPlaces[1]) annotation(Line(points = {{-70.7, 20}, {-65.1877, 20}, {-65.1877, 19.7952}, {-65.1877, 19.7952}}));
  connect('T1'.outPlaces[1], 'P2'.inTransition[1]) annotation(Line(points = {{-55.3, 20}, {-8.87372, 20}, {-8.87372, 20}, {-29.3, 20}}));
  connect('P2'.outTransition[1], 'T2'.inPlaces[1]) annotation(Line(points = {{-10.7, 20}, {13.9932, 20}, {13.9932, 19.4539}, {13.9932, 19.4539}}));
  connect('T2'.outPlaces[1], 'P3'.inTransition[1]) annotation(Line(points = {{24.7, 20}, {50.5119, 20}, {50.5119, 18.7713}, {50.5119, 18.7713}}));
  annotation(Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})));
end test2;

The tmp-variables are not generated correctly:

test2_model.h:

/* $TMP_'T1'$PpreliminarySpeed$PprelimSpeed_110 */
#define _$P$TMP_'T1'$PpreliminarySpeed$PprelimSpeed_110(i) data->localData[i]->realVars[52]
#define $P$TMP_'T1'$PpreliminarySpeed$PprelimSpeed_110 _$P$TMP_'T1'$PpreliminarySpeed$PprelimSpeed_110(0)
#define $P$PRE$P$TMP_'T1'$PpreliminarySpeed$PprelimSpeed_110 data->simulationInfo.realVarsPre[52]
#define $P$ATTRIBUTE$P$TMP_'T1'$PpreliminarySpeed$PprelimSpeed_110 data->modelData.realVarsData[52].attribute
#define $P$ATTRIBUTE$P$PRE$P$TMP_'T1'$PpreliminarySpeed$PprelimSpeed_110 $P$ATTRIBUTE$P$TMP_'T1'$PpreliminarySpeed$PprelimSpeed_110
#define $P$TMP_'T1'$PpreliminarySpeed$PprelimSpeed_110__varInfo data->modelData.realVarsData[52].info
#define $P$PRE$P$TMP_'T1'$PpreliminarySpeed$PprelimSpeed_110__varInfo data->modelData.realVarsData[52].info
#define _$P$PRE$P$TMP_'T1'$PpreliminarySpeed$PprelimSpeed_110(i) $P$PRE$P$TMP_'T1'$PpreliminarySpeed$PprelimSpeed_110

test2_02nls.c

void test2_eqFunction_54(DATA *data)
{
  [...]
  $P$TMP_'T2'$PpreliminarySpeed$PprelimSpeed_53 = 1.0;
  [...]
}

comment:4 by Mahder Alemseged Gebremedhin, 11 years ago

I think this has been fixed in r21201. All tests in the directory \testsuite\simulation\libraries\3rdParty\PNlib\ pass now.

Lennart if you verify if this is actually fixed the I will close this ticket.

Last edited 11 years ago by Lennart Ochel (previous) (diff)

comment:5 by Lennart Ochel, 11 years ago

No, this is still not fixed.

The example test2 from above is not part of the PNlib test suite (all examples from that folder are working fine, because no Q-IDENTs are used). Please check the model test2 from above.

comment:6 by Lennart Ochel, 11 years ago

Resolution: fixed
Status: reopenedclosed

You missed one case in your last commit. Now it seems to work.
Fixed in r20946, r21201 and r21203.

Note: See TracTickets for help on using tickets.