several mods

This commit is contained in:
pierre 1999-01-21 16:11:01 +00:00
parent 540c133628
commit 435e4de7fb
6 changed files with 93 additions and 12 deletions

View File

@ -3,13 +3,31 @@
{ but an error because the type casting is not considered at all! } { but an error because the type casting is not considered at all! }
{ Must be compiled with -Cr } { Must be compiled with -Cr }
{$ifdef go32v2}
uses dpmiexcp;
{$endif go32v2}
{$ifdef linux}
uses linux;
{$endif linux}
function our_sig(l : longint) : longint;
begin
{ If we land here the program works correctly !! }
Writeln('Bound check error signal recieved');
Halt(0);
end;
Var Var
Sel: Word; Sel: Word;
v: longint; v: longint;
Begin Begin
Signal(SIGSEGV,our_sig);
v:=$00ffffff; v:=$00ffffff;
Sel:=word(v); Sel:=word(v);
writeln(sel); writeln(sel);
{ should trigger Bound check error }
sel:=v; sel:=v;
{ we should not go to here }
Writeln('Error : signal not called');
Halt(1);
end. end.

View File

@ -4,7 +4,8 @@ var
begin begin
c:=1234; c:=1234;
writeln(c); writeln(c);
readln(c); {readln(c);}
c:=-258674;
writeln(c); writeln(c);
end. end.

View File

@ -4,4 +4,9 @@ const
drivestr:string='c:'; drivestr:string='c:';
pdrivestr:pstring=pstring(@drivestr); pdrivestr:pstring=pstring(@drivestr);
begin begin
if pdrivestr^<>'c:' then
begin
Writeln('Error in typecast of const');
Halt(1);
end;
end. end.

View File

@ -1,21 +1,34 @@
{ $OPT=-Cr }
program test; program test;
{$ifdef go32v2}
uses dpmiexcp;
{$endif go32v2}
type type
Tbaseclass = object Tbaseclass = object
base_arg : longint;
st_count : longint;static;
constructor Init; constructor Init;
destructor Done; destructor Done;
procedure Run; virtual; procedure Run; virtual;
end; end;
Totherclass = object(Tbaseclass) Totherclass = object(Tbaseclass)
other_arg : longint;
procedure Run; virtual; procedure Run; virtual;
end; end;
const
BaseRunCount : integer = 0;
OtherRunCount : integer = 0;
constructor Tbaseclass.Init; constructor Tbaseclass.Init;
begin begin
writeln('Init'); writeln('Init');
Inc(st_count);
Run; Run;
end; end;
@ -23,12 +36,14 @@ destructor Tbaseclass.Done;
begin begin
writeln('Done'); writeln('Done');
dec(st_count);
end; end;
procedure Tbaseclass.Run; procedure Tbaseclass.Run;
begin begin
writeln('Base method'); writeln('Base method');
inc(BaseRunCount);
end; end;
@ -36,11 +51,41 @@ procedure Totherclass.Run;
begin begin
writeln('Inherited method'); writeln('Inherited method');
inc(OtherRunCount);
end; end;
{ try this as local vars }
procedure test_local_class_init;
var base1 : TbaseClass;
var other1 : TOtherClass;
begin
with other1 do
Init;
with base1 do
Init;
with other1 do
begin
Writeln('number of objects = ',st_count);
base_arg:=2;
other_arg:=6;
Run;
end;
{ test if changed !! }
if (other1.base_arg<>2) or (other1.other_arg<>6) then
Halt(1);
with base1 do
begin
Run;
Done;
end;
other1.done;
end;
var base : Tbaseclass; var base : Tbaseclass;
other : Totherclass; other : Totherclass;
// asmrec : Tasmrec;
testfield : longint; testfield : longint;
begin begin
@ -61,6 +106,11 @@ begin
Done; Done;
end; end;
test_local_class_init;
{ Calls Tbaseclass.Run when it should call Totherclass.Run } { Calls Tbaseclass.Run when it should call Totherclass.Run }
If (BaseRunCount<>4) or (OtherRunCount<>4) then
Begin
Writeln('Error in tbs0187');
Halt(1);
End;
end. end.

View File

@ -18,9 +18,11 @@ const
pc : pchar = @s[1]; pc : pchar = @s[1];
begin begin
if (l^<>2) or (pc[1]<>'t') then Writeln(' l^ = ',l^);
Writeln('pc[0] = ',pc[0]);
if (l^<>2) or (pc[0]<>'t') then
Begin Begin
Writeln('Wrong code genrated'); Writeln('Wrong code generated');
RunError(1); RunError(1);
End; End;
end. end.

View File

@ -7,17 +7,22 @@ type rec = record
b : Word; b : Word;
end; end;
function x(r1 : rec; r2 : rec; var r3 : rec); assembler; { this is really for tests but
this should be coded with const r1 and r2 !! }
function x(r1 : rec; r2 : rec; var r3 : rec) : integer; assembler;
asm asm
movl r3, %edi movl r3, %edi
movl r1, %ebx
movl r1.a, %eax movl r2, %ecx
addl r2.a, %eax movl rec.a(%ebx), %eax
addl rec.a(%ecx), %eax
movl %eax, rec.a(%edi) movl %eax, rec.a(%edi)
movw r1.b, %cx movw rec.b(%ecx), %ax
addw r2.b, %cx addw rec.b(%edx), %ax
movw %cx, rec.b(%edi) movw %ax, rec.b(%edi)
movw $1,%ax
end; end;
var r1, r2, r3 : rec; var r1, r2, r3 : rec;