mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-26 04:09:18 +02:00
Fix for Mantis #27185.
ngenutil.pas: * AddToStructInits: also process the class constructors/destructors of nested types + added test git-svn-id: trunk@29308 -
This commit is contained in:
parent
0e9bfdcf68
commit
b38fb606cc
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -14172,6 +14172,7 @@ tests/webtbs/tw2710.pp svneol=native#text/plain
|
|||||||
tests/webtbs/tw27120.pp svneol=native#text/pascal
|
tests/webtbs/tw27120.pp svneol=native#text/pascal
|
||||||
tests/webtbs/tw2713.pp svneol=native#text/plain
|
tests/webtbs/tw2713.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw27153.pp svneol=native#text/pascal
|
tests/webtbs/tw27153.pp svneol=native#text/pascal
|
||||||
|
tests/webtbs/tw27185.pp svneol=native#text/pascal
|
||||||
tests/webtbs/tw2721.pp svneol=native#text/plain
|
tests/webtbs/tw2721.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw2723.pp svneol=native#text/plain
|
tests/webtbs/tw2723.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw2725.pp svneol=native#text/plain
|
tests/webtbs/tw2725.pp svneol=native#text/plain
|
||||||
|
@ -605,9 +605,14 @@ implementation
|
|||||||
StructList: TFPList absolute arg;
|
StructList: TFPList absolute arg;
|
||||||
begin
|
begin
|
||||||
if (tdef(p).typ in [objectdef,recorddef]) and
|
if (tdef(p).typ in [objectdef,recorddef]) and
|
||||||
not (df_generic in tdef(p).defoptions) and
|
not (df_generic in tdef(p).defoptions) then
|
||||||
([oo_has_class_constructor,oo_has_class_destructor] * tabstractrecorddef(p).objectoptions <> []) then
|
begin
|
||||||
StructList.Add(p);
|
{ first add the class... }
|
||||||
|
if ([oo_has_class_constructor,oo_has_class_destructor] * tabstractrecorddef(p).objectoptions <> []) then
|
||||||
|
StructList.Add(p);
|
||||||
|
{ ... and then also add all subclasses }
|
||||||
|
tabstractrecorddef(p).symtable.deflist.foreachcall(@AddToStructInits,arg);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
99
tests/webtbs/tw27185.pp
Normal file
99
tests/webtbs/tw27185.pp
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
program tw27185;
|
||||||
|
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
uses
|
||||||
|
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||||
|
cthreads,
|
||||||
|
{$ENDIF}{$ENDIF}
|
||||||
|
Classes
|
||||||
|
{ you can add units after this };
|
||||||
|
|
||||||
|
var
|
||||||
|
NormalClassInit: Boolean = False;
|
||||||
|
NormalClassDone: Boolean = False;
|
||||||
|
NestedTypeClassInit: Boolean = False;
|
||||||
|
NestedTypeClassDone: Boolean = False;
|
||||||
|
NestedTypeClassNestedClassInit: Boolean = False;
|
||||||
|
NestedTypeClassNestedClassDone: Boolean = False;
|
||||||
|
|
||||||
|
Type
|
||||||
|
|
||||||
|
{ TNormalClass }
|
||||||
|
|
||||||
|
TNormalClass = class
|
||||||
|
public
|
||||||
|
class constructor Create;
|
||||||
|
class destructor Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TNestedTypeClass }
|
||||||
|
|
||||||
|
TNestedTypeClass = class
|
||||||
|
private
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TNestedClass }
|
||||||
|
|
||||||
|
TNestedClass = class
|
||||||
|
public
|
||||||
|
class constructor Create;
|
||||||
|
class destructor Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
public
|
||||||
|
class constructor Create;
|
||||||
|
class destructor Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TNestedTypeClass }
|
||||||
|
|
||||||
|
class constructor TNestedTypeClass.Create;
|
||||||
|
begin
|
||||||
|
NestedTypeClassInit := True;
|
||||||
|
//WriteLn('class constructor TNestedTypeClass.Create');
|
||||||
|
end;
|
||||||
|
|
||||||
|
class destructor TNestedTypeClass.Destroy;
|
||||||
|
begin
|
||||||
|
NestedTypeClassDone := True;
|
||||||
|
//WriteLn('class destructor TNestedTypeClass.Destroy');
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TNormalClass }
|
||||||
|
|
||||||
|
class constructor TNormalClass.Create;
|
||||||
|
begin
|
||||||
|
NormalClassInit := True;
|
||||||
|
//WriteLn('class constructor TNormalClass.Create');
|
||||||
|
end;
|
||||||
|
|
||||||
|
class destructor TNormalClass.Destroy;
|
||||||
|
begin
|
||||||
|
NormalClassDone := False;
|
||||||
|
//WriteLn('class destructor TNormalClass.Destroy');
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TNestedTypeClass.TNestedClass }
|
||||||
|
|
||||||
|
class constructor TNestedTypeClass.TNestedClass.Create;
|
||||||
|
begin
|
||||||
|
NestedTypeClassNestedClassInit := True;
|
||||||
|
//WriteLn('class constructor TNestedTypeClass.TNestedClass.Create');
|
||||||
|
end;
|
||||||
|
|
||||||
|
class destructor TNestedTypeClass.TNestedClass.Destroy;
|
||||||
|
begin
|
||||||
|
NestedTypeClassNestedClassDone := True;
|
||||||
|
//WriteLn('class destructor TNestedTypeClass.TNestedClass.Destroy');
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
if not NormalClassInit then
|
||||||
|
Halt(1);
|
||||||
|
if not NestedTypeClassInit then
|
||||||
|
Halt(2);
|
||||||
|
if not NestedTypeClassNestedClassInit then
|
||||||
|
Halt(3);
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user