Skip to content

pointer to record broken #87

@norayr

Description

@norayr
MODULE test;
TYPE
  something* = POINTER TO RECORD
    length-: LONGINT; (* current length of string excluding 0X *)
    bufferSize: LONGINT; (* {bufferSize >= InitialSize} *)
  END;

END test.
MODULE test2;
IMPORT test;
VAR
  s: test.something;
BEGIN
NEW(s);
END test2.

NEW generates wrong code here, so

 $ voc -s test.Mod test2.Mod -m
test.Mod  Compiling test.  New symbol file.  471 chars.
test2.Mod  Compiling test2.  Main program.  453 chars.
In file included from test2.c:8:
test2.c: In function ‘main’:
test2.c:29:17: error: ‘test2__1__typ’ undeclared (first use in this function); did you mean ‘test__1__typ’?
   29 |  __NEW(test2_s, test2__1);
      |                 ^~~~~~~~
/opt/voc/2/include/SYSTEM.h:280:51: note: in definition of macro ‘__NEW’
  280 | #define __NEW(p, t)      p = Heap_NEWREC((ADDRESS)t##__typ)
      |                                                   ^
test2.c:29:17: note: each undeclared identifier is reported only once for each function it appears in
   29 |  __NEW(test2_s, test2__1);
      |                 ^~~~~~~~
/opt/voc/2/include/SYSTEM.h:280:51: note: in definition of macro ‘__NEW’
  280 | #define __NEW(p, t)      p = Heap_NEWREC((ADDRESS)t##__typ)
      |                                                   ^
C compile and link: gcc -fPIC -g -I "/opt/voc/2/include"  test2.c  test.o -o test2 -L"/opt/voc/lib" -lvoc-O2
-- failed: status 0, exitcode 1.
Terminated by Halt(1).

the workaround is using POINTER TO somethingDesc and then having somethingDesc to be the same as POINTER TO RECORD now.

still, this is a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions