mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-05-31 20:02:40 +02:00

40307 40309 40314 40319 40322 40324 40326 40377 40378 from trunk to fixes_3_2 ------------------------------------------------------------------------ r40277 | pierre | 2018-11-08 20:18:30 +0000 (Thu, 08 Nov 2018) | 1 line Implement mark_write override for tinilinenode ------------------------------------------------------------------------ --- Merging r40277 into '.': U compiler/ninl.pas --- Recording mergeinfo for merge of r40277 into '.': U . ------------------------------------------------------------------------ r40307 | pierre | 2018-11-13 15:10:21 +0000 (Tue, 13 Nov 2018) | 6 lines + Introduce PPC_SUFFIXES, new make variable that lists all ppc suffixes for all different CPUs supported. * Use PPC_SUFFIXES in execlean and CPU_clean targets. * Also delete CPU/bin subbirectory. ------------------------------------------------------------------------ --- Merging r40307 into '.': U compiler/Makefile U compiler/Makefile.fpc --- Recording mergeinfo for merge of r40307 into '.': G . ------------------------------------------------------------------------ r40309 | pierre | 2018-11-13 15:51:32 +0000 (Tue, 13 Nov 2018) | 1 line Try to avoid expectloc not set after first pass error for call node ------------------------------------------------------------------------ --- Merging r40309 into '.': U compiler/ncal.pas --- Recording mergeinfo for merge of r40309 into '.': G . ------------------------------------------------------------------------ r40314 | pierre | 2018-11-14 13:13:19 +0000 (Wed, 14 Nov 2018) | 4 lines * Change first parameter type of function is_continuous_maks to aword type. Add typecasts where needed to allow for successful compilation of arm-linux target with -CriotR options when building the compiler. ------------------------------------------------------------------------ --- Merging r40314 into '.': U compiler/arm/cpubase.pas U compiler/arm/cgcpu.pas --- Recording mergeinfo for merge of r40314 into '.': G . ------------------------------------------------------------------------ r40319 | pierre | 2018-11-15 16:58:40 +0000 (Thu, 15 Nov 2018) | 1 line Disable range check in m68k:tiscv32 and riscv64 cgcpu units ------------------------------------------------------------------------ --- Merging r40319 into '.': C compiler/riscv64 U compiler/m68k/cgcpu.pas C compiler/riscv32 --- Recording mergeinfo for merge of r40319 into '.': G . Summary of conflicts: Tree conflicts: 2 ------------------------------------------------------------------------ r40322 | pierre | 2018-11-15 22:01:25 +0000 (Thu, 15 Nov 2018) | 1 line Also disable range checking in arm/aoptcpu unit ------------------------------------------------------------------------ --- Merging r40322 into '.': U compiler/arm/aoptcpu.pas --- Recording mergeinfo for merge of r40322 into '.': G . ------------------------------------------------------------------------ r40324 | pierre | 2018-11-16 10:27:42 +0000 (Fri, 16 Nov 2018) | 4 lines * Disable range check for m68k/aoptcpu unit * Add missing change of var parameter p to next instruction in TryToOptimizeMove method after instruction removal. ------------------------------------------------------------------------ --- Merging r40324 into '.': U compiler/m68k/aoptcpu.pas --- Recording mergeinfo for merge of r40324 into '.': G . ------------------------------------------------------------------------ r40326 | pierre | 2018-11-16 13:28:26 +0000 (Fri, 16 Nov 2018) | 1 line Change local variables offsetdec and extraoffset type to ASizeInt ------------------------------------------------------------------------ --- Merging r40326 into '.': U compiler/ncgmem.pas --- Recording mergeinfo for merge of r40326 into '.': G . ------------------------------------------------------------------------ r40377 | pierre | 2018-11-27 10:19:36 +0000 (Tue, 27 Nov 2018) | 1 line Fix bug report 34605 and add corresponding test ------------------------------------------------------------------------ --- Merging r40377 into '.': A tests/webtbs/tw34605.pp U compiler/nutils.pas --- Recording mergeinfo for merge of r40377 into '.': G . ------------------------------------------------------------------------ r40378 | pierre | 2018-11-27 10:21:37 +0000 (Tue, 27 Nov 2018) | 1 line Avoid range errors or overflows on for AVR cpu, when computing address offsets ------------------------------------------------------------------------ --- Merging r40378 into '.': U compiler/ncgset.pas U compiler/ngtcon.pas --- Recording mergeinfo for merge of r40378 into '.': G . git-svn-id: branches/fixes_3_2@40716 -
137 lines
2.2 KiB
ObjectPascal
137 lines
2.2 KiB
ObjectPascal
{%OPT=-CR}
|
|
|
|
{ This test checks that correct code is generated
|
|
when typecasting a class reference type variable with a descendent class }
|
|
|
|
{$mode objfpc}
|
|
|
|
uses
|
|
sysutils;
|
|
|
|
type
|
|
|
|
TBaseClass = class
|
|
constructor Create;
|
|
class var x : longint;
|
|
var loc : longint;
|
|
class procedure check; virtual;
|
|
end;
|
|
|
|
TDerClass = class(TBaseClass)
|
|
var der : longint;
|
|
end;
|
|
|
|
TDer1Class = class(TDerClass)
|
|
constructor Create;
|
|
class var y : longint;
|
|
var loc1 : longint;
|
|
class procedure check; override;
|
|
end;
|
|
|
|
TDer2Class = class(TDerClass)
|
|
constructor Create;
|
|
class var z : longint;
|
|
var loc2 : longint;
|
|
class procedure check; override;
|
|
end;
|
|
|
|
constructor TBaseClass.Create;
|
|
begin
|
|
Inherited Create;
|
|
x:=1;
|
|
end;
|
|
|
|
constructor TDer1Class.Create;
|
|
begin
|
|
Inherited Create;
|
|
y:=1;
|
|
end;
|
|
|
|
constructor TDer2Class.Create;
|
|
begin
|
|
Inherited Create;
|
|
z:=1;
|
|
end;
|
|
|
|
class procedure TBaseClass.check;
|
|
begin
|
|
writeln('TBaseClass.check called');
|
|
end;
|
|
|
|
class procedure TDer1Class.check;
|
|
begin
|
|
writeln('TDer1Class.check called');
|
|
end;
|
|
|
|
class procedure TDer2Class.check;
|
|
begin
|
|
writeln('TDer2Class.check called');
|
|
end;
|
|
|
|
type
|
|
TBaseClassRef = class of TBaseClass;
|
|
TDerClassRef = class of TDerClass;
|
|
|
|
var
|
|
c : TBaseClass;
|
|
cc : TBaseClassRef;
|
|
dcc : TDerClassRef;
|
|
exception_generated : boolean;
|
|
|
|
begin
|
|
exception_generated:=false;
|
|
c:=TBaseClass.Create;
|
|
|
|
inc(c.x);
|
|
c.check;
|
|
c.free;
|
|
|
|
c:=TDer1Class.Create;
|
|
|
|
inc(c.x);
|
|
inc(TDer1Class(c).y);
|
|
c.check;
|
|
c.free;
|
|
|
|
c:=TDer2Class.Create;
|
|
inc(c.x);
|
|
inc(TDer2Class(c).z);
|
|
c.check;
|
|
c.free;
|
|
|
|
cc:=TbaseClass;
|
|
inc(cc.x);
|
|
cc.check;
|
|
|
|
cc:=TDer1Class;
|
|
inc(cc.x);
|
|
cc.check;
|
|
|
|
|
|
cc:=TDer2Class;
|
|
inc(cc.x);
|
|
cc.check;
|
|
TDerClassRef(cc).check;
|
|
TDerClass(cc).check;
|
|
|
|
dcc:=TDerClass;
|
|
dcc.check;
|
|
|
|
try
|
|
//inc (TDer1Class(cc).y);
|
|
TDer1Class(cc).check;
|
|
except
|
|
writeln('Exception generated');
|
|
exception_generated:=true;
|
|
end;
|
|
writeln('TBaseClass: x=',TBaseClass.x);
|
|
writeln('TDer1Class: x=',TDer1Class.x,', y=',TDer1Class.y);
|
|
writeln('TDer2Class: x=',TDer2Class.x,', z=',TDer2Class.z);
|
|
if not exception_generated then
|
|
begin
|
|
writeln('No exception generated on wrong typecast of class reference variable');
|
|
halt(1);
|
|
end;
|
|
end.
|
|
|