Opened 13 years ago
Closed 7 years ago
#1680 closed defect (fixed)
Error in generated C code for arrays with undetermined size
Reported by: | chenouard-r | Owned by: | chenouard-r |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Code Generation | Version: | |
Keywords: | Cc: | chenouard-r |
Description (last modified by )
I build a "simple" example with a model and a function based on an array of an undetermined size. I think I conformed to Modelica language, but some other Modelica compilers also don't achieve in executing this code (mainly a problem with my use of sum function). The modelica code and 2 of the main C files generated by OpenModelica are joined as attached files. I use OpenModelica Compiler 1.8.0 (r10946).
I got the following errors when compiling:
Test.Test1.c: In function ‘eqFunction_3’: Test.Test1.c:279: error: expected expression before ‘:’ token Test.Test1.c:289: error: ‘$P$reductionFoldTmpA’ undeclared (first use in this function) Test.Test1.c:289: error: (Each undeclared identifier is reported only once Test.Test1.c:289: error: for each function it appears in.) Test.Test1.c:289: error: ‘$P$reductionFoldTmpB’ undeclared (first use in this function) Test.Test1.c: In function ‘eqFunction_6’: Test.Test1.c:385: error: expected expression before ‘:’ token Test.Test1.c:395: error: ‘$P$reductionFoldTmpA’ undeclared (first use in this function) Test.Test1.c:395: error: ‘$P$reductionFoldTmpB’ undeclared (first use in this function)
I suppose there is a problem when reformulating and generating the C code. The ':' symbol is used to state C arrays and some temporary variables are not define before use.
Attachments (3)
Change History (6)
by , 13 years ago
by , 13 years ago
Attachment: | _Test.Test1.h added |
---|
comment:1 by , 13 years ago
comment:2 by , 12 years ago
Cc: | chenouard-r, → chenouard-r |
---|---|
Component: | → Backend |
Description: | modified (diff) |
comment:3 by , 9 years ago
Milestone: | → Future |
---|
comment:4 by , 7 years ago
Component: | Backend → Code Generation |
---|---|
Milestone: | Future |
Resolution: | → fixed |
Status: | new → closed |
This was fixed at some point.
This is somewhat hard to fix easily. I added a better error-message though. Implementation note: Either fix the cref to have type ARRAY(... DIM_EXP(n-1)) or fix codegen to take both dimension and expression to backpatch dimensions. I like the former better than the latter.