mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 07:29:25 +02:00
* fixed for optimization loading
This commit is contained in:
parent
82f2bbd2db
commit
1381adee4b
@ -4,12 +4,11 @@
|
|||||||
program test;
|
program test;
|
||||||
type trec = record i:integer; s:ansistring end;
|
type trec = record i:integer; s:ansistring end;
|
||||||
|
|
||||||
procedure RefCount(const s : ansistring;expect:longint);
|
procedure RefCount(const s : ansistring;var rc:sizeint;expect:sizeint);
|
||||||
type
|
type
|
||||||
PLongint = ^Longint;
|
PLongint = ^Longint;
|
||||||
var
|
var
|
||||||
P : psizeint;
|
P : psizeint;
|
||||||
rc : longint;
|
|
||||||
begin
|
begin
|
||||||
P := psizeint(s);
|
P := psizeint(s);
|
||||||
rc:=0;
|
rc:=0;
|
||||||
@ -25,9 +24,14 @@ begin
|
|||||||
{$else}
|
{$else}
|
||||||
rc:=plongint(pchar(p)-8)^;
|
rc:=plongint(pchar(p)-8)^;
|
||||||
{$endif}
|
{$endif}
|
||||||
writeln('Ref count is ',rc,' expected ',expect);
|
if expect<>-1 then
|
||||||
if rc<>expect then
|
begin
|
||||||
halt(1);
|
writeln('Ref count is ',rc,' expected ',expect);
|
||||||
|
if rc<>expect then
|
||||||
|
halt(1);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
writeln('Ref count is ',rc);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -48,17 +52,18 @@ procedure p4(a:ansistring);
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
var r:trec; s:ansistring;
|
var r:trec; s:ansistring;
|
||||||
|
hrc,rc : sizeint;
|
||||||
begin
|
begin
|
||||||
s:=chr(ord('A')+random(26));
|
s:=chr(ord('A')+random(26));
|
||||||
r.s:=s;
|
r.s:=s;
|
||||||
writeln('init');
|
writeln('init');
|
||||||
RefCount(s,3);
|
RefCount(s,rc,-1);
|
||||||
writeln('p1()');
|
writeln('p1()');
|
||||||
p1(r);
|
p1(r);
|
||||||
RefCount(s,3);
|
RefCount(s,hrc,rc);
|
||||||
writeln('p2()');
|
writeln('p2()');
|
||||||
p2(r);
|
p2(r);
|
||||||
RefCount(s,3);
|
RefCount(s,hrc,rc);
|
||||||
writeln('ok');
|
writeln('ok');
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user